//
//  XLNetWorkManager.m
//  SSReader
//
//  Created by xundu on 2019/6/27.
//  Copyright © 2019 SS_soft. All rights reserved.
//

#import "XLNetWorkManager.h"
#import "SSBaseModel.h"
//#import "ZZMessageHud.h"
#import "NSString+SS.h"
//#import "NSDate+XLDate.h"
@implementation XLNetWorkManager

static id _instance = nil;
+ (instancetype)shareInstance {
    return [[self alloc] init];
}

+ (instancetype)allocWithZone:(struct _NSZone *)zone {
    
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        _instance = [super allocWithZone:zone];
    });
    return _instance;
}

- (instancetype)init {
    
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        _instance = [super init];
        
    });
    return _instance;
}


- (NSURLSessionDataTask *)POSTBody:(NSString *)finalURL withContentType:(NSString *)ContentTypeStr parameters:(id)parameters success:(void (^)(id _Nonnull responseObject))success failure:(void (^)(NSError * _Nonnull error))failure {
    
    XSWeakSelf;
    
    
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
        
    /**
     *  可以接受的类型
     */
    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
    [manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Accept"];


    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript", nil];
    
    if(ContentTypeStr){
        [manager.requestSerializer setValue:ContentTypeStr forHTTPHeaderField:@"Content-Type"];
    }else{
        [manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
    }
//    [manager.requestSerializer setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
    /**
     *  请求超时的时间
     */
    manager.requestSerializer.timeoutInterval = 100;
    NSString *token = [[NSUserDefaults standardUserDefaults] valueForKey:@"token"];
    if (token) {
        [manager.requestSerializer setValue:token  forHTTPHeaderField:@"Authorization"];
//        NSLog(@"API_memberPlaceOrder--用户token==%@\n",token);
    }else{
        if([SSUserManager sharedUser].userModel.tempToken){
            token = [SSUserManager sharedUser].userModel.tempToken;
//            NSLog(@"API_memberPlaceOrder--访客token==%@\n",token);
            
            [manager.requestSerializer setValue:token  forHTTPHeaderField:@"Authorization"];
        }
        else{
            [manager.requestSerializer setValue:@"Basic Y2xpZW50LWFwOjFxYXp4c3cy"  forHTTPHeaderField:@"Authorization"];
        }
    }
    
    //NSString *finalURL = [API_BASEURL stringByAppendingString:url];
    
    
//    NSString *jsonString2;
//    NSMutableString *dataStr2 = [NSMutableString new];
//
//    NSDictionary *parametersData2 = parameters;
//    if(parametersData2.allKeys.count>0){
//        for (int i = 0; i < parametersData2.count;  i ++) {
//            NSString *key = parametersData2.allKeys[i];
//            id value = parametersData2[key];
//            [dataStr2 appendFormat:@"%@=%@&",key,value];
//        }
//        NSString *postStr = [dataStr2 substringWithRange:NSMakeRange(0, dataStr2.length - 1)];
//        jsonString2 = [postStr URLEncodedString];
//    }else{
//        jsonString2 =[[NSString new] URLEncodedString];
//    }
//    finalURL = [NSString stringWithFormat:@"%@?%@",finalURL,jsonString2];
    
    
    NSLog(@"请求的URL：%@",finalURL);
    NSMutableURLRequest * request = [manager.requestSerializer requestWithMethod:@"POST" URLString:finalURL parameters:parameters error:nil];
    
    NSString *jsonString;
    if(ContentTypeStr){
        [request setValue:ContentTypeStr forHTTPHeaderField:@"Content-Type"];
        
        
        NSMutableString *dataStr = [NSMutableString new];
       
        NSDictionary *parametersData = parameters;
        if([parametersData isKindOfClass:[NSDictionary class]]){
//            if(parametersData.allKeys.count>0){
//                for (int i = 0; i < parametersData.count;  i ++) {
//                    NSString *key = parametersData.allKeys[i];
//                    id value = parametersData[key];
//                    [dataStr appendFormat:@"%@=%@&",key,value];
//                }
//                NSString *postStr = [dataStr substringWithRange:NSMakeRange(0, dataStr.length - 1)];
//                jsonString = postStr;
//            }else{
//                jsonString =[NSString new];
//            }
           jsonString = [NSString convertToJsonData:parametersData];
        }
        else{
            jsonString =[NSString new];
        }
        
    }else{
        [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
        
        NSData *jsonData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
        jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
        if(kStringIsEmpty(jsonString)){
            jsonString = [NSString new];
        }
    }
    

//    NSData *jsonData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
//    NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];

    NSData *bodyData = [jsonString dataUsingEncoding:NSUTF8StringEncoding];
    if(!bodyData){
        bodyData = [NSData new];
    }
    [request setHTTPBody:bodyData];
    
    NSURLSessionDataTask *task = [manager.session dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
        dispatch_async(dispatch_get_main_queue(), ^{
            if (error !=nil) {
                if (failure) {
                    failure(error);
                }
                
            }else{
                if (data) {
                    NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:nil];
//                    NSLog(@"finalURL===%@\n请求响应：%@",finalURL,dict);
                    [weakSelf successHandling:dict requestUrl:finalURL];
                    if (!dict) {
                        
#warning 暂时注释
#warning 暂时注释
#warning 暂时注释
#warning 暂时注释
//                        [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"token"];
//                        [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"cloudRootNodeID"];
//                        [[NSUserDefaults standardUserDefaults] synchronize];
//                        [[NSNotificationCenter defaultCenter] postNotificationName:@"authorLoginAccess" object:nil];

//                        [ZZMessageHud showMessage:@"登录失效，请重新登录" toView:[UIApplication sharedApplication].windows.firstObject];

                        NSDictionary *eroDict = @{@"code":@"401",@"msg":@"登录失效",@"data":@""};
                        if (success) {
                            success(eroDict);
                        }
                        return;
                    }
                    if (success) {
                        success(dict);
                    }
                    
                }
            }
        });
    }];
    [task resume];
    return task;
}



- (NSURLSessionDataTask *)GET:(NSString *)url parameters:(id)parameters modelType:(Class)model success:(void (^)(NSInteger, NSString * _Nonnull, id _Nonnull))success failure:(void (^)(NSError * _Nonnull))failure {
    
    XSWeakSelf;
    
    NSURLSessionDataTask *task = [self GET:url parameters:parameters progress:^(NSProgress * _Nonnull downloadProgress) {
        
    } success:^(id  _Nonnull responseObject) {
        
//        NSLog(@"finalURL===%@\n请求响应：%@",url,parameters);
        id modelData = [[model class] yy_modelWithJSON:responseObject];
        if ([modelData isKindOfClass:[SSBaseModel class]]) {
            
            SSBaseModel *baseModle = (SSBaseModel *)modelData;
            if (success) {
                success(baseModle.code,baseModle.msg,modelData);
            }
           
        }else{
            if (success) {
                success(0,@"",modelData);
            }
        }
        [weakSelf successHandling:responseObject requestUrl:url];
        
    } failure:^(NSError * _Nonnull error) {
   
        if (failure) {
            failure(error);
        }
    }];
    
    return task;
}
- (void)extracted:(void (^ _Nonnull)(NSError * _Nonnull))failure model:(__unsafe_unretained Class _Nonnull)model parameters:(id _Nonnull)parameters success:(void (^ _Nonnull)(NSInteger, NSString * _Nonnull, id _Nonnull))success urlApi:(NSString *)urlApi {
    XSWeakSelf;
    [self GET:urlApi parameters:parameters progress:^(NSProgress * _Nonnull downloadProgress) {
        
    } success:^(id  _Nonnull responseObject) {
        
//        NSLog(@"finalURL===%@\n请求响应：%@",urlApi,parameters);
        dispatch_async(dispatch_get_main_queue(), ^{
        id modelData = [[model class] yy_modelWithJSON:responseObject];
        if ([modelData isKindOfClass:[SSBaseModel class]]) {
            SSBaseModel *baseModle = (SSBaseModel *)modelData;
            if (success) {
                success(baseModle.code,baseModle.msg,modelData);
            }
        }else{
            if (success) {
                success(0,@"",modelData);
            }
        }
        });
        [weakSelf successHandling:responseObject requestUrl:urlApi];
    } failure:^(NSError * _Nonnull error) {
       
        if (failure) {
            failure(error);
        }
    }];
}



/**
 *  发送get请求
 */
- (NSURLSessionDataTask *)GET:(NSString *)url
                   parameters:(id)parameters
          httpHeaderKeyValues:(NSDictionary *)header
                     progress:(void (^)(NSProgress *downloadProgress))downloadProgressBlock
                      success:(void (^)(id responseObject))success
                      failure:(void (^)(NSError *error))failure {
    
    XSWeakSelf;
    
    
    

    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];

    /**
     *  请求超时的时间
     */
    manager.requestSerializer.timeoutInterval = 100;

    NSString *finalURL = [API_BASEURL stringByAppendingString:url];

    //finalURL = [finalURL stringByAppendingString:paramStr];
    NSString *token = [[NSUserDefaults standardUserDefaults] valueForKey:@"token"];

    manager.requestSerializer = [AFHTTPRequestSerializer serializer];


    if (token) {
        [manager.requestSerializer setValue:token  forHTTPHeaderField:@"Authorization"];
//        [manager.requestSerializer setValue:token  forHTTPHeaderFieldAction:@"Authorization"];
    }else{
        if([SSUserManager sharedUser].userModel.tempToken){
            token = [SSUserManager sharedUser].userModel.tempToken;
            NSLog(@"API_memberPlaceOrder--访客token==%@\n",token);

            [manager.requestSerializer setValue:token  forHTTPHeaderField:@"Authorization"];
        }
    }

//    NSLog(@"getMethod--token==%@\n",token);
    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"text/plain",
                                                         @"multipart/form-data",
                                                         @"application/json",
                                                         @"text/html",
                                                         @"image/jpeg",
                                                         @"image/png",
                                                         @"image/jpg",
                                                         @"application/octet-stream",
                                                         @"text/json", nil];
     
     NSURLSessionDataTask *task22 =[manager GET:finalURL parameters:parameters headers:@{} progress:^(NSProgress * _Nonnull downloadProgress) {
        
    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        //        NSLog(@"GET66===请求响应：%@",responseObject);
                if (responseObject) {

                    NSDictionary *dict;
                    if([responseObject isKindOfClass:[NSDictionary class]]){
                        dict = responseObject;
                    }else{
                        dict = [NSJSONSerialization JSONObjectWithData:(NSData *)responseObject options:kNilOptions error:nil];
                    }

                    if (dict == nil) {//检查是否能解密
                        NSString *result = [[NSString alloc] initWithData:(NSData *)responseObject encoding:NSUTF8StringEncoding];
        //                NSLog(@"finalURL===%@\n请求响应：%@  result==%@\n",finalURL,dict,result);
                        NSData *resulSSata = [result dataUsingEncoding:NSUTF8StringEncoding];
                        if (resulSSata) {
                            dict = [NSJSONSerialization JSONObjectWithData:resulSSata options:kNilOptions error:nil];
                        }
                    }
                    if (dict != nil) {
                        success(dict);
                    }else{
                        NSError *error = [NSError errorWithDomain:NSMachErrorDomain code:-100 userInfo:@{NSLocalizedDescriptionKey : @"网络数据解析错误"}];
                        failure(error);
                    }
                }
                [weakSelf successHandling:responseObject requestUrl:finalURL];

            } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
                NSLog(@"GET666===请求响应：%@",NSError.description);
                failure(error);
            }];
    
    return task22;

}

- (NSURLSessionDataTask *)GET:(NSString *)url
                   parameters:(id)parameters
                     progress:(void (^)(NSProgress *downloadProgress))downloadProgressBlock
                      success:(void (^)(id responseObject))success
                      failure:(void (^)(NSError *error))failure {

    
    
    NSURLSessionDataTask *task = [self GET:url parameters:parameters httpHeaderKeyValues:@{} progress:downloadProgressBlock success:success failure:failure];
    return task;
}




/**
 *  发送post请求
 */
- (NSURLSessionDataTask *)POST:(NSString *)url
                    parameters:(id)parameters
                       success:(void (^)(id responseObject))success
                       failure:(void (^)(NSError *error))failure {
    
    XSWeakSelf;
    
    
    

    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
    
    /**
     *  可以接受的类型
     */
    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
    
    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript", nil];
    [manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
    [manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Accept"];

    /**
     *  请求超时的时间
     */
    manager.requestSerializer.timeoutInterval = 100;
//    if(![url isEqualToString:API_forgotPassword]){
//        NSString *token = [[NSUserDefaults standardUserDefaults] valueForKey:@"token"];
//        NSLog(@"🏃🏃🏃🏃===token==%@\n",token);
//        if (token) {
//            [manager.requestSerializer setValue:token  forHTTPHeaderField:@"Authorization"];
//    //        [manager.requestSerializer setValue:token  forHTTPHeaderFieldAction:@"Authorization"];
//        }else{
//            if([SSUserManager sharedUser].userModel.tempToken){
//                token = [SSUserManager sharedUser].userModel.tempToken;
//                NSLog(@"API_memberPlaceOrder--访客token==%@\n",token);
//
//                [manager.requestSerializer setValue:token  forHTTPHeaderField:@"Authorization"];
//            }
//        }
//    }
//    else{
//        //[headerDic setValue:@"Basic Y2xpZW50LWFwOjFxYXp4c3cy" forKey:@"Authorization"];
//        [manager.requestSerializer setValue:@"Basic Y2xpZW50LWFwOjFxYXp4c3cy"  forHTTPHeaderField:@"Authorization"];
//    }
    
    
    NSString *token = [[NSUserDefaults standardUserDefaults] valueForKey:@"token"];
    NSLog(@"🏃🏃🏃🏃===token==%@\n",token);
    
//XLBaesNavigationController *currontVc = [SSUntil currentNC];
//UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"token" message:token preferredStyle:UIAlertControllerStyleAlert];
//UIAlertAction *confirm = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
//    
//}];
////            UIAlertAction *cancel = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil];
//[alert addAction:confirm];
////            [alert addAction:cancel];
//dispatch_async(dispatch_get_main_queue(), ^{
//    [currontVc presentViewController:alert animated:YES completion:nil];
//});
    
    if (token) {
        [manager.requestSerializer setValue:token  forHTTPHeaderField:@"Authorization"];
//        [manager.requestSerializer setValue:token  forHTTPHeaderFieldAction:@"Authorization"];
    }else{
        if([SSUserManager sharedUser].userModel.tempToken){
            token = [SSUserManager sharedUser].userModel.tempToken;
            NSLog(@"API_memberPlaceOrder--访客token==%@\n",token);
            
            [manager.requestSerializer setValue:token  forHTTPHeaderField:@"Authorization"];
        }
    }
    
    NSDictionary *finalParams = parameters;
    NSString *finalURL = url;//[API_BASEURLh5 stringByAppendingString:url];
    NSMutableString *paramStr = [NSMutableString stringWithString:finalURL];
    for (NSString *key in finalParams.allKeys) {
        if ([finalParams.allKeys indexOfObject:key] == 0) {
            [paramStr appendFormat:@"?%@=%@",key,finalParams[key]];
        } else {
            [paramStr appendFormat:@"&%@=%@",key,finalParams[key]];
        }
    }
    finalURL = paramStr;
    finalURL = [finalURL stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
    NSLog(@"请求的URL：%@",finalURL);
    

    NSMutableURLRequest * request = [manager.requestSerializer requestWithMethod:@"POST" URLString:finalURL parameters:parameters error:nil];
    request.HTTPMethod = @"POST";
    NSURLSessionDataTask *task = [manager.session dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
        
        
       dispatch_async(dispatch_get_main_queue(), ^{
           if (error !=nil) {
               if (failure) {
                   failure(error);
               }
           }else{
               if (data) {
                   NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:nil];
                   if(!dict){
                       NSString *tempstr = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
                       
                       NSData *messageData = [tempstr dataUsingEncoding:NSUTF8StringEncoding];
                       dict = [NSJSONSerialization JSONObjectWithData:messageData options:kNilOptions error:nil];
                   }
//                   NSLog(@"finalURL===%@\n请求响应：%@",finalURL,dict);
                   if (!dict) {
                       
                       [weakSelf successHandling:dict requestUrl:finalURL];

//                       if([finalURL containsString:API_duplicatecheckGetDuplicDataByBody]){// 这里是查重提交内容  返回的data是没有数据的
//
//                       }else{
//
//                       }
#warning 暂时注释
#warning 暂时注释
#warning 暂时注释
#warning 暂时注释
//   [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"token"];
//   [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"cloudRootNodeID"];
//   [[NSUserDefaults standardUserDefaults] synchronize];
//
//   [[NSNotificationCenter defaultCenter] postNotificationName:@"authorLoginAccess" object:nil];
//                       [ZZMessageHud showMessage:@"登录失效，请重新登录" toView:[UIApplication sharedApplication].windows.firstObject];

                       NSDictionary *eroDict = @{@"code":@"401",@"msg":@"登录失效",@"data":@""};
                       if (success) {
                           success(eroDict);
                       }
                       return;
                   }
                   if (success) {
                       [weakSelf successHandling:dict requestUrl:finalURL];
                       success(dict);
                   }
                   
               }
           }
       });
        
        
    }];
    [task resume];
    return task;
}

- (NSURLSessionDataTask *)POST:(NSString *)url
                    parameters:(id)parameters
                     modelType:(Class)modelType
                       success:(void (^)(id _Nonnull))success
                       failure:(void (^)(NSError * _Nonnull))failure {
    
    XSWeakSelf;
    
    
    
    
    
 return  [self POST:url parameters:parameters success:^(id  _Nonnull responseObject) {
        id modelData = [[modelType class] yy_modelWithJSON:responseObject];
        if (success) {
            success(modelData);
        }
    } failure:^(NSError * _Nonnull error) {
        if (failure) {
            failure(error);
        }
    }];
}


/**
 *  上传文件
 */
- (NSURLSessionDataTask *)upload:(NSString *)url
                      parameters:(id)parameters
             httpHeaderKeyValues:(NSDictionary *)header
       constructingBodyWithBlock:(void (^)(id <AFMultipartFormData> formData))formDataBlock
                         success:(void (^)(id responseObject))success
                         failure:(void (^)(NSError *error))failure {
    
    XSWeakSelf;
    
    
    
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
    
    /**
     *  可以接受的类型
     */
    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
    manager.requestSerializer = [AFJSONRequestSerializer serializer];
    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript", @"text/plain",@"text/html", nil];
    
    /**
     *  请求超时的时间
     */
    manager.requestSerializer.timeoutInterval = 100;

    
    [manager.requestSerializer setValue:@"multipart/form-data" forHTTPHeaderField:@"Content-Type"];
    
  
    NSString *token = [[NSUserDefaults standardUserDefaults] valueForKey:@"token"];
    if (token) {
        [manager.requestSerializer setValue:token  forHTTPHeaderField:@"Authorization"];
    }else{
        if([SSUserManager sharedUser].userModel.tempToken){
            token = [SSUserManager sharedUser].userModel.tempToken;
            NSLog(@"API_memberPlaceOrder--访客token==%@\n",token);
            
            [manager.requestSerializer setValue:token  forHTTPHeaderField:@"Authorization"];
        }
    }
    
    NSDictionary *finalParams = parameters;
    NSString *finalURL;
//    if([url isEqualToString:API_userWechatQqParserWord]){
////    转换html接口：http://poi.writemall.com/user/wechatQqParserWord
//        finalURL = [@"http://poi.writemall.com" stringByAppendingString:url];
//    }else{
//        finalURL = [API_BASEURL stringByAppendingString:url];
//    }
    
    finalURL = url;
//    NSString *finalURL = [API_BASEURL stringByAppendingString:url];
//    NSMutableString *paramStr = [NSMutableString stringWithString:finalURL];
//    for (NSString *key in finalParams.allKeys) {
//        if ([finalParams.allKeys indexOfObject:key] == 0) {
//            [paramStr appendFormat:@"?%@=%@",key,finalParams[key]];
//        } else {
//            [paramStr appendFormat:@"&%@=%@",key,finalParams[key]];
//        }
//    }
//    finalURL = paramStr;
    NSLog(@"请求的URL：%@",finalURL);
    //NSURLSessionDataTask *task =[NSURLSessionDataTask new];
    return [manager POST:finalURL parameters:parameters headers:header constructingBodyWithBlock:^(id<AFMultipartFormData>  _Nonnull formData) {
        if (formDataBlock) {
            formDataBlock(formData);
        }
    } progress:^(NSProgress * _Nonnull uploadProgress) {
        
    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:responseObject options:kNilOptions error:nil];
        [weakSelf successHandling:dict requestUrl:finalURL];
//        NSLog(@"finalURL===%@\n请求响应：%@",finalURL,dict);
       if (success) {
           success(dict);
       }
   } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
       if (failure) {
           failure(error);
       }
   }];
}



- (NSURLSessionDataTask *)upload:(NSString *)url
                      parameters:(id)parameters
       constructingBodyWithBlock:(void (^)(id <AFMultipartFormData> formData))formDataBlock
                         success:(void (^)(id responseObject))success
                         failure:(void (^)(NSError *error))failure {
    
    XSWeakSelf;
    
    
    return [self upload:url parameters:parameters httpHeaderKeyValues:@{} constructingBodyWithBlock:formDataBlock success:success failure:failure];
}




/**
 *  下载
 */
- (NSURLSessionDownloadTask *)download:(NSString *)url
                            parameters:(id)parameters
                   httpHeaderKeyValues:(NSDictionary *)header
                              progress:(void (^)(NSProgress *downloadProgress))downloadProgressBlock
                           destination:(NSURL * (^)(NSURL *targetPath, NSURLResponse *response))destination
                     completionHandler:(void (^)(NSURLResponse *response, NSURL *filePath, NSError *error))completionHandler {
    
    NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration];
    AFURLSessionManager *manager = [[AFURLSessionManager alloc] initWithSessionConfiguration:configuration];
    NSDictionary *finalParams = parameters;
    NSString *finalURL = API_BASEURL;
    if ([url hasPrefix:@"http"]) {
        finalURL = url;
    }else{
        finalURL = [API_BASEURL stringByAppendingString:url];
    }
    
    NSMutableString *paramStr = [NSMutableString stringWithString:finalURL];
    
    for (NSString *key in finalParams.allKeys) {
        if ([finalParams.allKeys indexOfObject:key] == 0) {
            [paramStr appendFormat:@"?%@=%@",key,finalParams[key]];
        } else {
            [paramStr appendFormat:@"&%@=%@",key,finalParams[key]];
        }
    }
    finalURL = paramStr;
    finalURL = [finalURL  stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
    NSLog(@"请求的URL：%@",finalURL);
    NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:finalURL]];
//    request.HTTPMethod = @"POST";
    
    NSURLSessionDownloadTask *task = [manager downloadTaskWithRequest:request progress:downloadProgressBlock destination:destination completionHandler:completionHandler];
    [task resume];
    return task;
}

- (NSURLSessionDownloadTask *)download:(NSString *)url
                            parameters:(id)parameters
                              progress:(void (^)(NSProgress *downloadProgress))downloadProgressBlock
                           destination:(NSURL * (^)(NSURL *targetPath, NSURLResponse *response))destination
                     completionHandler:(void (^)(NSURLResponse *response, NSURL *filePath, NSError *error))completionHandler {
    return [self download:url parameters:parameters httpHeaderKeyValues:@{} progress:downloadProgressBlock destination:destination completionHandler:completionHandler];
}

- (NSURLSessionDataTask *)upload:(NSString *)url
                            port:(NSString *)portStr
                      parameters:(id)parameters
       constructingBodyWithBlock:(void (^)(id <AFMultipartFormData> formData))formDataBlock
                         success:(void (^)(id responseObject))success
                         failure:(void (^)(NSError *error))failure {
    
    XSWeakSelf;
    
    
    return [self upload:url port:portStr parameters:parameters httpHeaderKeyValues:@{} constructingBodyWithBlock:formDataBlock success:success failure:failure];
}


/**
 *  上传文件
 */
- (NSURLSessionDataTask *)upload:(NSString *)url
                            port:(NSString *)portStr
                      parameters:(id)parameters
             httpHeaderKeyValues:(NSDictionary *)header
       constructingBodyWithBlock:(void (^)(id <AFMultipartFormData> formData))formDataBlock
                         success:(void (^)(id responseObject))success
                         failure:(void (^)(NSError *error))failure {
    
    XSWeakSelf;
    
    
    
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
    
    /**
     *  可以接受的类型
     */
    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
    manager.requestSerializer = [AFJSONRequestSerializer serializer];
    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript", @"text/plain",@"text/html", nil];
    
    /**
     *  请求超时的时间
     */
    manager.requestSerializer.timeoutInterval = 100;

    
    [manager.requestSerializer setValue:@"multipart/form-data" forHTTPHeaderField:@"Content-Type"];
    
  
    NSString *token = [[NSUserDefaults standardUserDefaults] valueForKey:@"token"];
    if (token) {
        [manager.requestSerializer setValue:token  forHTTPHeaderField:@"Authorization"];
    }else{
        if([SSUserManager sharedUser].userModel.tempToken){
            token = [SSUserManager sharedUser].userModel.tempToken;
            NSLog(@"API_memberPlaceOrder--访客token==%@\n",token);
            
            [manager.requestSerializer setValue:token  forHTTPHeaderField:@"Authorization"];
        }
    }
    
    NSDictionary *finalParams = parameters;

    NSString *TempFinalURL = [API_BASEURL stringByAppendingString:portStr];
    NSString *finalURL = [NSString stringWithFormat:@"%@%@",TempFinalURL,url];
    
    
    NSMutableString *paramStr = [NSMutableString stringWithString:finalURL];
    for (NSString *key in finalParams.allKeys) {
        if ([finalParams.allKeys indexOfObject:key] == 0) {
            [paramStr appendFormat:@"?%@=%@",key,finalParams[key]];
        } else {
            [paramStr appendFormat:@"&%@=%@",key,finalParams[key]];
        }
    }
    finalURL = paramStr;
    NSLog(@"请求的URL：%@",finalURL);
    
    NSURLSessionDataTask *task = [manager POST:finalURL parameters:parameters headers:@{@"Authorization":token} constructingBodyWithBlock:^(id<AFMultipartFormData>  _Nonnull formData) {
        if (formDataBlock) {
            formDataBlock(formData);
        }
    } progress:^(NSProgress * _Nonnull uploadProgress) {
        
    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:responseObject options:kNilOptions error:nil];
        [weakSelf successHandling:dict requestUrl:finalURL];
//        NSLog(@"finalURL===%@\n请求响应：%@",finalURL,dict);
       if (success) {
           success(dict);
       }
   } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        if (failure) {
            failure(error);
        }
    }];
    return task;
}



/**
 *  发送Put请求
 */
- (void)PutContentUrl:(NSString *)url
       parameters:(id)parameters
          success:(void (^)(id responseObject))success
          failure:(void (^)(NSError *error))failure {
    
    XSWeakSelf;
    
    
    
    
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
    
    /**
     *  可以接受的类型
     */
    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
    
    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript", nil];
    [manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
    [manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Accept"];

    /**
     *  请求超时的时间
     */
    manager.requestSerializer.timeoutInterval = 100;
    NSString *token = [[NSUserDefaults standardUserDefaults] valueForKey:@"token"];
    NSLog(@"🏃🏃🏃🏃===token==%@\nurl==%@\n",token,url);
    if (token) {
        [manager.requestSerializer setValue:token  forHTTPHeaderField:@"Authorization"];
//        [manager.requestSerializer setValue:token  forHTTPHeaderFieldAction:@"Authorization"];
    }else{
        if([SSUserManager sharedUser].userModel.tempToken){
            token = [SSUserManager sharedUser].userModel.tempToken;
            NSLog(@"API_memberPlaceOrder--访客token==%@\n",token);
            
            [manager.requestSerializer setValue:token  forHTTPHeaderField:@"Authorization"];
        }
    }
    
//    NSDictionary *finalParams = parameters;
    NSString *finalURL = [API_BASEURL stringByAppendingString:url];
    NSMutableString *paramStr = [NSMutableString stringWithString:finalURL];
    
//    NSString *TempFinalURL = [API_BASEURL stringByAppendingString:portStr];
//    NSString *finalURL = [NSString stringWithFormat:@"%@%@",TempFinalURL,url];
//    NSLog(@"请求的URL：%@",finalURL);
    
    
    
//    for (NSString *key in finalParams.allKeys) {
//        if ([finalParams.allKeys indexOfObject:key] == 0) {
//            [paramStr appendFormat:@"?%@=%@",key,finalParams[key]];
//        } else {
//            [paramStr appendFormat:@"&%@=%@",key,finalParams[key]];
//        }
//    }
    finalURL = paramStr;
    finalURL = [finalURL stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
    
    
    NSLog(@"请求的URL：%@",finalURL);
    
    [manager PUT:finalURL parameters:parameters headers:@{} success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        NSDictionary *dict = responseObject;
        [weakSelf successHandling:dict requestUrl:finalURL];
        if (!dict) {



//                       if([finalURL containsString:API_duplicatecheckGetDuplicDataByBody]){// 这里是查重提交内容  返回的data是没有数据的
//
//                       }else{
//
//                       }
#warning 暂时注释
#warning 暂时注释
#warning 暂时注释
#warning 暂时注释
//                       [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"token"];
//                       [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"cloudRootNodeID"];
//                       [[NSUserDefaults standardUserDefaults] synchronize];
//
//                       [[NSNotificationCenter defaultCenter] postNotificationName:@"authorLoginAccess" object:nil];
//            [ZZMessageHud showMessage:@"登录失效，请重新登录" toView:[UIApplication sharedApplication].windows.firstObject];

            NSDictionary *eroDict = @{@"code":@"401",@"msg":@"登录失效",@"data":@""};
            if (success) {
                success(eroDict);
            }
            return;
        }
        if (success) {
            success(dict);
        }

        } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
            failure(error);
        }];
//    [manager PUT:finalURL parameters:parameters success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
//        NSDictionary *dict = responseObject;
//        if (!dict) {
//
//
//
////                       if([finalURL containsString:API_duplicatecheckGetDuplicDataByBody]){// 这里是查重提交内容  返回的data是没有数据的
////
////                       }else{
////
////                       }
//#warning 暂时注释
//#warning 暂时注释
//#warning 暂时注释
//#warning 暂时注释
////                       [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"token"];
////                       [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"cloudRootNodeID"];
////                       [[NSUserDefaults standardUserDefaults] synchronize];
////
////                       [[NSNotificationCenter defaultCenter] postNotificationName:@"authorLoginAccess" object:nil];
////            [ZZMessageHud showMessage:@"登录失效，请重新登录" toView:[UIApplication sharedApplication].windows.firstObject];
//
//            NSDictionary *eroDict = @{@"code":@"401",@"msg":@"登录失效",@"data":@""};
//            if (success) {
//                success(eroDict);
//            }
//            return;
//        }
//        if (success) {
//            success(dict);
//        }
//
//        } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
//            failure(error);
//        }];
    
    
    
    
}


#pragma mark - 统一获取验证码
- (NSURLSessionDataTask *)POSTBodyYanZhengCodeLogin:(NSString *)url parameters:(id)parameters success:(void (^)(id _Nonnull))success failure:(void (^)(NSError * _Nonnull))failure {
    
    XSWeakSelf;
    
    
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
        
    /**
     *  可以接受的类型
     */
    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
    [manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Accept"];


    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript", nil];
    [manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
//    [manager.requestSerializer setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
    
    
    
    
    /**
     *  请求超时的时间
     */
    manager.requestSerializer.timeoutInterval = 100;
    
    if([url isEqualToString:API_getMobileAchCaptchas]){
        [manager.requestSerializer setValue:@"Basic Y2xpZW50LWFwOjFxYXp4c3cy" forHTTPHeaderField:@"Authorization"];
    }
    else{
        NSString *token = [[NSUserDefaults standardUserDefaults] valueForKey:@"token"];
        if (!kStringIsEmpty(token)) {
            [manager.requestSerializer setValue:token  forHTTPHeaderField:@"Authorization"];
        }else{
            if(!kStringIsEmpty([SSUserManager sharedUser].userModel.tempToken)){
                token = [SSUserManager sharedUser].userModel.tempToken;
                  NSLog(@"API_memberPlaceOrder--访客token==%@\n",token);
                
                [manager.requestSerializer setValue:token  forHTTPHeaderField:@"Authorization"];
            }else{
                
                [manager.requestSerializer setValue:@"Basic Y2xpZW50LWFwOjFxYXp4c3cy" forHTTPHeaderField:@"Authorization"];
            }
        }
    }
    
    NSString *finalURL = [getVertificationCode_BASEURL stringByAppendingString:url];
      NSLog(@"请求的URL：%@",finalURL);
    NSMutableURLRequest * request = [manager.requestSerializer requestWithMethod:@"POST" URLString:finalURL parameters:parameters error:nil];
    NSData *jsonData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
    NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
    NSLog(@"\n\njsonString==\n\n%@\n\n",jsonString);
    NSData *bodyData = [jsonString dataUsingEncoding:NSUTF8StringEncoding];
    [request setHTTPBody:bodyData];
    request.HTTPMethod = @"POST";
    NSURLSessionDataTask *task = [manager.session dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
        
          NSLog(@"url==%@ error---20202020==%@\n",finalURL,error.description);
        dispatch_async(dispatch_get_main_queue(), ^{
            if (error !=nil) {
                if (failure) {
                    failure(error);
                }
                
            }else{
                if (data) {
                    NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:nil];
                    [weakSelf successHandling:dict requestUrl:finalURL];
//                      NSLog(@"finalURL===%@\n请求响应：%@",finalURL,dict);
                    if (!dict) {
                        
#warning 暂时注释
#warning 暂时注释
#warning 暂时注释
#warning 暂时注释
//                        [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"token"];
//                        [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"cloudRootNodeID"];
//                        [[NSUserDefaults standardUserDefaults] synchronize];
//                        [[NSNotificationCenter defaultCenter] postNotificationName:@"authorLoginAccess" object:nil];

//                        [ZZMessageHud showMessage:@"登录失效，请重新登录" toView:[UIApplication sharedApplication].windows.firstObject];

                        NSDictionary *eroDict = @{@"code":@"401",@"msg":@"登录失效",@"data":@""};
                        if (success) {
                            success(eroDict);
                        }
                        return;
                    }
                    if (success) {
                        success(dict);
                    }
                    
                }
            }
        });
    }];
    [task resume];
    return task;
}

-(void)successHandling:(NSDictionary*)resDic requestUrl:(NSString*)urlStr{
    
    if([resDic isKindOfClass:[NSData class]]){
        resDic = [NSJSONSerialization JSONObjectWithData:(NSData *)resDic options:kNilOptions error:nil];;
    }
    if ([resDic objectForKey:@"code"] == nil) {
        
        return;
    }
    if ([[resDic objectForKey:@"code"] integerValue] == 200) {
        
    }else if([[resDic objectForKey:@"code"] integerValue] == 401){
        
        [self appRootJumpLoginViewControllerWithStatuCodeNumber:401];
    }else{
        NSLog(@"successHandling--resDic==%@\n %@",urlStr,resDic);
        NSString *messageStr = [NSString stringWithFormat:@"%@",[resDic objectForKey:@"message"]];
        
    }
}

- (void)appRootJumpLoginViewController:(NSInteger)statuCodelNum{
//    [_instance cancelAllOperations];
    [[_instance operationQueue] cancelAllOperations];
    
    if(statuCodelNum==401){
        
        NSLog(@"您的账号在其他地方登录,如果不是本人操作请重置账号密5555码");
//        return;
        UIAlertController *alert = [UIAlertController alertControllerWithTitle:kLocalizedString(@"温馨提示") message:kLocalizedString(@"您的账号在其他地方登录,如果不是本人操作请重置账号密码") preferredStyle:UIAlertControllerStyleAlert];
        
        XSWeakSelf;
        UIAlertAction *confirm = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
            
            [weakSelf createUserTempData];
//dispatch_async(dispatch_get_main_queue(), ^{
//    [(KAppDelegate) showLoginViewController];
//});
        }];
        //            UIAlertAction *cancel = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil];
        [alert addAction:confirm];
        //            [alert addAction:cancel];
        dispatch_async(dispatch_get_main_queue(), ^{
            [[YSHelp getCurrentVC] presentViewController:alert animated:YES completion:nil];
        });
    }
    else{
//        dispatch_async(dispatch_get_main_queue(), ^{
//            [(KAppDelegate) showLoginViewController];
//        });
    }
    
}
// statuCodelNum 401 token过期
- (void)appRootJumpLoginViewControllerWithStatuCodeNumber:(NSInteger)statuCodelNum{
    [_instance cancelAllOperations];
    
    if(statuCodelNum==401){
        
        NSLog(@"您的账号在其他地方登录,如果不是本人操作请重置账号密码666");
        //return;
        UIAlertController *alert = [UIAlertController alertControllerWithTitle:kLocalizedString(@"温馨提示") message:kLocalizedString(@"您的账号在其他地方登录,如果不是本人操作请重置账号密码") preferredStyle:UIAlertControllerStyleAlert];
        XSWeakSelf;
        UIAlertAction *confirm = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
            [weakSelf createUserTempData];
//dispatch_async(dispatch_get_main_queue(), ^{
//    [(KAppDelegate) showLoginViewControllerWithStatuCodeNumber:statuCodelNum];
//});
        }];
        //            UIAlertAction *cancel = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil];
        [alert addAction:confirm];
        //            [alert addAction:cancel];
        dispatch_async(dispatch_get_main_queue(), ^{
            [[YSHelp getCurrentVC] presentViewController:alert animated:YES completion:nil];
        });
    }
    else{
//        dispatch_async(dispatch_get_main_queue(), ^{
//            [(KAppDelegate) showLoginViewControllerWithStatuCodeNumber:statuCodelNum];
//        });
    }
    
}

- (void)cancelAllOperations{
    [[_instance operationQueue] cancelAllOperations];
}

- (void)createUserTempData{
    [[NSUserDefaults standardUserDefaults] setObject:[NSString new] forKey:@"token"];
    [[NSUserDefaults standardUserDefaults] setObject:[NSString new] forKey:@"WritemallToken"];
    
    
    [[NSUserDefaults standardUserDefaults] setObject:[NSString new] forKey:@"AutoLoginNowDateKey"];
    //[[NSUserDefaults standardUserDefaults]setObject:[NSString new] forKey:@"fanChaoXieAccountKey"];
    [[NSUserDefaults standardUserDefaults]setObject:[NSString new] forKey:@"fanChaoXiePwdKey"];
   
    
//        [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"cloudRootNodeID"];
    [[NSUserDefaults standardUserDefaults] synchronize];
    [SSUserManager sharedUser].isLoginSuccess = NO;
//            [[NSNotificationCenter defaultCenter] postNotificationName:KUserInfoLoginOutNotification object:nil];
    
    NSString*uuid=[CMUUIDManager readUUID];
    if(kStringIsEmpty(uuid)){
    uuid = [NSString new];
    }


    [SSUserManager sharedUser].userModel.mobile = [uuid copy];
}


#pragma mark -- =====================



- (NSURLSessionDataTask *)POSTBody:(NSString *)url parameters:(id)parameters success:(void (^)(id _Nonnull))success failure:(void (^)(NSError * _Nonnull))failure {
    
    XSWeakSelf;
    
    
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
        
    /**
     *  可以接受的类型
     */
    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
    [manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Accept"];


    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript", nil];
    [manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
//    [manager.requestSerializer setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
    
    
    
    
    /**
     *  请求超时的时间
     */
    manager.requestSerializer.timeoutInterval = 100;
    NSString *token = [[NSUserDefaults standardUserDefaults] valueForKey:@"token"];
    if (token) {
        [manager.requestSerializer setValue:token  forHTTPHeaderField:@"Authorization"];
    }else{
        if([SSUserManager sharedUser].userModel.tempToken){
            token = [SSUserManager sharedUser].userModel.tempToken;
            NSLog(@"API_memberPlaceOrder--访客token==%@\n",token);
            
            [manager.requestSerializer setValue:token  forHTTPHeaderField:@"Authorization"];
        }else{
            
            [manager.requestSerializer setValue:@"Basic Y2xpZW50LWFwOjFxYXp4c3cy" forHTTPHeaderField:@"Authorization"];
        }
    }
    
    NSString *finalURL = [API_BASEURL stringByAppendingString:url];
    NSLog(@"请求的URL：%@",finalURL);
    NSMutableURLRequest * request = [manager.requestSerializer requestWithMethod:@"POST" URLString:finalURL parameters:parameters error:nil];
    NSData *jsonData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
    NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
    NSLog(@"\n\njsonString==\n\n%@\n\n",jsonString);
    NSData *bodyData = [jsonString dataUsingEncoding:NSUTF8StringEncoding];
    [request setHTTPBody:bodyData];
    request.HTTPMethod = @"POST";
    NSURLSessionDataTask *task = [manager.session dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
        dispatch_async(dispatch_get_main_queue(), ^{
            if (error !=nil) {
                if (failure) {
                    failure(error);
                }
                
            }else{
                if (data) {
                    NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:nil];
                    [weakSelf successHandling:dict requestUrl:finalURL];
//                    NSLog(@"finalURL===%@\n请求响应：%@",finalURL,dict);
                    if (!dict) {
                        
#warning 暂时注释
#warning 暂时注释
#warning 暂时注释
#warning 暂时注释
//                        [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"token"];
//                        [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"cloudRootNodeID"];
//                        [[NSUserDefaults standardUserDefaults] synchronize];
//                        [[NSNotificationCenter defaultCenter] postNotificationName:@"authorLoginAccess" object:nil];

//                        [ZZMessageHud showMessage:@"登录失效，请重新登录" toView:[UIApplication sharedApplication].windows.firstObject];

                        NSDictionary *eroDict = @{@"code":@"401",@"msg":@"登录失效",@"data":@""};
                        if (success) {
                            success(eroDict);
                        }
                        return;
                    }
                    if (success) {
                        success(dict);
                    }
                    
                }
            }
        });
    }];
    [task resume];
    return task;
}
- (NSURLSessionDataTask *)POSTBody:(NSString *)url timeOut:(NSTimeInterval)tout parameters:(id)parameters success:(void (^)(id _Nonnull))success failure:(void (^)(NSError * _Nonnull))failure {
    
    XSWeakSelf;
    
    
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
        
    /**
     *  可以接受的类型
     */
    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
    [manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Accept"];


    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript", nil];
    [manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
//    [manager.requestSerializer setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
    
    
    
    
    /**
     *  请求超时的时间
     */
    manager.requestSerializer.timeoutInterval = 100;
    if(tout>0){
        manager.requestSerializer.timeoutInterval = tout;
    }
    NSString *token = [[NSUserDefaults standardUserDefaults] valueForKey:@"token"];
    if (token) {
        [manager.requestSerializer setValue:token  forHTTPHeaderField:@"Authorization"];
    }else{
        if([SSUserManager sharedUser].userModel.tempToken){
            token = [SSUserManager sharedUser].userModel.tempToken;
            NSLog(@"API_memberPlaceOrder--访客token==%@\n",token);
            
            [manager.requestSerializer setValue:token  forHTTPHeaderField:@"Authorization"];
        }else{
            
            [manager.requestSerializer setValue:@"Basic Y2xpZW50LWFwOjFxYXp4c3cy" forHTTPHeaderField:@"Authorization"];
        }
    }
    
    NSString *finalURL = [API_BASEURL stringByAppendingString:url];
    NSLog(@"请求的URL：%@",finalURL);
    NSMutableURLRequest * request = [manager.requestSerializer requestWithMethod:@"POST" URLString:finalURL parameters:parameters error:nil];
    NSData *jsonData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
    NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
    NSLog(@"\n\njsonString==\n\n%@\n\n",jsonString);
    NSData *bodyData = [jsonString dataUsingEncoding:NSUTF8StringEncoding];
    [request setHTTPBody:bodyData];
    request.HTTPMethod = @"POST";
    NSURLSessionDataTask *task = [manager.session dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
        dispatch_async(dispatch_get_main_queue(), ^{
            if (error !=nil) {
                if (failure) {
                    failure(error);
                }
                
            }else{
                if (data) {
                    NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:nil];
//                    NSLog(@"finalURL===%@\n请求响应：%@",finalURL,dict);
                    [weakSelf successHandling:dict requestUrl:finalURL];
                    if (!dict) {
                        
#warning 暂时注释
#warning 暂时注释
#warning 暂时注释
#warning 暂时注释
//                        [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"token"];
//                        [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"cloudRootNodeID"];
//                        [[NSUserDefaults standardUserDefaults] synchronize];
//                        [[NSNotificationCenter defaultCenter] postNotificationName:@"authorLoginAccess" object:nil];

//                        [ZZMessageHud showMessage:@"登录失效，请重新登录" toView:[UIApplication sharedApplication].windows.firstObject];

                        NSDictionary *eroDict = @{@"code":@"401",@"msg":@"登录失效",@"data":@""};
                        if (success) {
                            success(eroDict);
                        }
                        return;
                    }
                    if (success) {
                        success(dict);
                    }
                    
                }
            }
        });
    }];
    [task resume];
    return task;
}


- (NSURLSessionDataTask *)POSTBody:(NSString *)url withrequestSerializerContentType:(NSString *)requestSerializerContentType parameters:(id)parameters success:(void (^)(id _Nonnull responseObject))success failure:(void (^)(NSError * _Nonnull error))failure {
    
    XSWeakSelf;
    
    
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
        
    /**
     *  可以接受的类型
     */
    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
    [manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Accept"];


    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript", nil];
    
    if(requestSerializerContentType){
        [manager.requestSerializer setValue:requestSerializerContentType forHTTPHeaderField:@"Content-Type"];
    }else{
        [manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
    }
//    [manager.requestSerializer setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
    /**
     *  请求超时的时间
     */
    manager.requestSerializer.timeoutInterval = 100;
    NSString *token = [[NSUserDefaults standardUserDefaults] valueForKey:@"token"];
    if (token) {
        [manager.requestSerializer setValue:token  forHTTPHeaderField:@"Authorization"];
//        NSLog(@"API_memberPlaceOrder--用户token==%@\n",token);
    }else{
        if([SSUserManager sharedUser].userModel.tempToken){
            token = [SSUserManager sharedUser].userModel.tempToken;
//            NSLog(@"API_memberPlaceOrder--访客token==%@\n",token);
            
            [manager.requestSerializer setValue:token  forHTTPHeaderField:@"Authorization"];
        }
        else{
            [manager.requestSerializer setValue:@"Basic Y2xpZW50LWFwOjFxYXp4c3cy"  forHTTPHeaderField:@"Authorization"];
        }
    }
    
    NSString *finalURL = [API_BASEURL stringByAppendingString:url];
    
    
//    NSString *jsonString2;
//    NSMutableString *dataStr2 = [NSMutableString new];
//
//    NSDictionary *parametersData2 = parameters;
//    if(parametersData2.allKeys.count>0){
//        for (int i = 0; i < parametersData2.count;  i ++) {
//            NSString *key = parametersData2.allKeys[i];
//            id value = parametersData2[key];
//            [dataStr2 appendFormat:@"%@=%@&",key,value];
//        }
//        NSString *postStr = [dataStr2 substringWithRange:NSMakeRange(0, dataStr2.length - 1)];
//        jsonString2 = [postStr URLEncodedString];
//    }else{
//        jsonString2 =[[NSString new] URLEncodedString];
//    }
//    finalURL = [NSString stringWithFormat:@"%@?%@",finalURL,jsonString2];
    
    
    NSLog(@"请求的URL：%@",finalURL);
    NSMutableURLRequest * request = [manager.requestSerializer requestWithMethod:@"POST" URLString:finalURL parameters:parameters error:nil];
    
    NSString *jsonString;
    if(requestSerializerContentType){
        [request setValue:requestSerializerContentType forHTTPHeaderField:@"Content-Type"];
        
        
        NSMutableString *dataStr = [NSMutableString new];
       
        NSDictionary *parametersData = parameters;
        if([parametersData isKindOfClass:[NSDictionary class]]){
//            if(parametersData.allKeys.count>0){
//                for (int i = 0; i < parametersData.count;  i ++) {
//                    NSString *key = parametersData.allKeys[i];
//                    id value = parametersData[key];
//                    [dataStr appendFormat:@"%@=%@&",key,value];
//                }
//                NSString *postStr = [dataStr substringWithRange:NSMakeRange(0, dataStr.length - 1)];
//                jsonString = postStr;
//            }else{
//                jsonString =[NSString new];
//            }
           jsonString = [NSString convertToJsonData:parametersData];
        }
        else{
            jsonString =[NSString new];
        }
        
    }else{
        [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
        
        NSData *jsonData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
        jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
        if(kStringIsEmpty(jsonString)){
            jsonString = [NSString new];
        }
    }
    

//    NSData *jsonData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
//    NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];

    NSData *bodyData = [jsonString dataUsingEncoding:NSUTF8StringEncoding];
    if(!bodyData){
        bodyData = [NSData new];
    }
    [request setHTTPBody:bodyData];
    
    NSURLSessionDataTask *task = [manager.session dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
        dispatch_async(dispatch_get_main_queue(), ^{
            if (error !=nil) {
                if (failure) {
                    failure(error);
                }
                
            }else{
                if (data) {
                    NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:nil];
//                    NSLog(@"finalURL===%@\n请求响应：%@",finalURL,dict);
                    [weakSelf successHandling:dict requestUrl:finalURL];
                    if (!dict) {
                        
#warning 暂时注释
#warning 暂时注释
#warning 暂时注释
#warning 暂时注释
//                        [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"token"];
//                        [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"cloudRootNodeID"];
//                        [[NSUserDefaults standardUserDefaults] synchronize];
//                        [[NSNotificationCenter defaultCenter] postNotificationName:@"authorLoginAccess" object:nil];

//                        [ZZMessageHud showMessage:@"登录失效，请重新登录" toView:[UIApplication sharedApplication].windows.firstObject];

                        NSDictionary *eroDict = @{@"code":@"401",@"msg":@"登录失效",@"data":@""};
                        if (success) {
                            success(eroDict);
                        }
                        return;
                    }
                    if (success) {
                        success(dict);
                    }
                    
                }
            }
        });
    }];
    [task resume];
    return task;
}


- (NSURLSessionDataTask *)GETBody:(NSString *)url withrequestSerializerContentType:(NSString *)requestSerializerContentType parameters:(id)parameters success:(void (^)(id _Nonnull sucee))success failure:(void (^)(NSError * _Nonnull err))failure {
    
    XSWeakSelf;
    
    
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
        
    /**
     *  可以接受的类型
     */
    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
    [manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Accept"];


    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript", nil];
    
    if(requestSerializerContentType){
        [manager.requestSerializer setValue:requestSerializerContentType forHTTPHeaderField:@"Content-Type"];
    }else{
        [manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
    }
//    [manager.requestSerializer setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
    /**
     *  请求超时的时间
     */
    manager.requestSerializer.timeoutInterval = 100;
    NSString *token = [[NSUserDefaults standardUserDefaults] valueForKey:@"token"];
    if (token) {
        [manager.requestSerializer setValue:token  forHTTPHeaderField:@"Authorization"];
        NSLog(@"API_memberPlaceOrder--用户token==%@\n",token);
    }else{
        if([SSUserManager sharedUser].userModel.tempToken){
            token = [SSUserManager sharedUser].userModel.tempToken;
            NSLog(@"API_memberPlaceOrder--访客token==%@\n",token);
            
            [manager.requestSerializer setValue:token  forHTTPHeaderField:@"Authorization"];
        }
    }
    
    
    
    NSString *finalURL = [API_BASEURL stringByAppendingString:url];
    
//            NSMutableString *dataStr = [NSMutableString new];
//    NSString *jsonString;
//            NSDictionary *parametersData = parameters;
//            if(parametersData.allKeys.count>0){
//                for (int i = 0; i < parametersData.count;  i ++) {
//                    NSString *key = parametersData.allKeys[i];
//                    id value = parametersData[key];
//                    [dataStr appendFormat:@"%@=%@&",key,value];
//                }
//                NSString *postStr = [dataStr substringWithRange:NSMakeRange(0, dataStr.length - 1)];
//                jsonString = postStr;
//            }else{
//                jsonString =[NSString new];
//            }
//    if(jsonString.length>0){
//        finalURL = [NSString stringWithFormat:@"%@?%@",finalURL,jsonString];
//    }
    
//    NSLog(@"请求的jsonString==%@",jsonString);
    NSLog(@"请求的UR==%@",finalURL);
    NSMutableURLRequest * request = [manager.requestSerializer requestWithMethod:@"GET" URLString:finalURL parameters:parameters error:nil];
    request.HTTPMethod = @"GET";
//    NSString *jsonString;
    if(requestSerializerContentType){
        [request setValue:requestSerializerContentType forHTTPHeaderField:@"Content-Type"];
        
        
//        NSMutableString *dataStr = [NSMutableString new];
//
//        NSDictionary *parametersData = parameters;
//        if(parametersData.allKeys.count>0){
//            for (int i = 0; i < parametersData.count;  i ++) {
//                NSString *key = parametersData.allKeys[i];
//                id value = parametersData[key];
//                [dataStr appendFormat:@"%@=%@&",key,value];
//            }
//            NSString *postStr = [dataStr substringWithRange:NSMakeRange(0, dataStr.length - 1)];
//            jsonString = postStr;
//        }else{
//            jsonString =[NSString new];
//        }
        
    }else{
        [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
        
//        NSData *jsonData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
//        jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
//        if(kStringIsEmpty(jsonString)){
//            jsonString = [NSString new];
//        }
    }
    

//    NSData *jsonData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
//    NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];

//    NSData *bodyData = [jsonString dataUsingEncoding:NSUTF8StringEncoding];
//    if(!bodyData){
//        bodyData = [NSData new];
//    }
//    [request setHTTPBody:bodyData];
    
    NSURLSessionDataTask *task = [manager.session dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
        dispatch_async(dispatch_get_main_queue(), ^{
            if (error !=nil) {
                if (failure) {
                    failure(error);
                }
                
            }else{
                if (data) {
                    NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:nil];
//                    NSLog(@"finalURL===%@\n请求响应：%@",finalURL,dict);
                    [weakSelf successHandling:dict requestUrl:finalURL];
                    if (!dict) {
                        
#warning 暂时注释
#warning 暂时注释
#warning 暂时注释
#warning 暂时注释
//                        [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"token"];
//                        [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"cloudRootNodeID"];
//                        [[NSUserDefaults standardUserDefaults] synchronize];
//                        [[NSNotificationCenter defaultCenter] postNotificationName:@"authorLoginAccess" object:nil];

//                        [ZZMessageHud showMessage:@"登录失效，请重新登录" toView:[UIApplication sharedApplication].windows.firstObject];

//                        NSDictionary *eroDict = @{@"code":@"401",@"msg":@"登录失效",@"data":@""};
//                        if (success) {
//                            success(eroDict);
//                        }
//                        return;
                        NSDictionary *tempDictData = [NSDictionary new];
//                                if (data) {
//                                    NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:nil];
//                //                    NSLog(@"finalURL===%@\n请求响应：%@",finalURL,dict);
//                                    if (dict) {
//                                        tempDictData = dict;
//                                    }
//
//                                }
                                
                                NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)response;
                                if(httpResponse.statusCode==200){
                                    if (success) {
                                        
                                        if(tempDictData){
                                            success(@{@"message":@"成功",@"data":tempDictData,@"code":@"200"});
                                        }else{
                                            success(@{@"message":@"成功",@"data":@"null",@"code":@"200"});
                                        }
                                    }
                                }
                                else{
                                    
            #warning 暂时注释
            #warning 暂时注释
            #warning 暂时注释
            #warning 暂时注释
            //                        [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"token"];
            //                        [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"cloudRootNodeID"];
            //                        [[NSUserDefaults standardUserDefaults] synchronize];
            //                        [[NSNotificationCenter defaultCenter] postNotificationName:@"authorLoginAccess" object:nil];

        //                            [ZZMessageHud showMessage:@"登录失效，请重新登录" toView:[UIApplication sharedApplication].windows.firstObject];
                                    
                                    NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)response;
                                    if(httpResponse.statusCode==500){
                                        NSDictionary *eroDict = @{@"code":@"500",@"msg":@"系统繁忙",@"data":@""};
                                        if (success) {
                                            success(eroDict);
                                        }
                                        return;
                                    }
                                    else{
                                        NSDictionary *eroDict = @{@"code":@"401",@"msg":@"登录失效",@"data":@""};
                                        if (success) {
                                            success(eroDict);
                                        }
                                        return;
                                    }
                        }
                    }
                    if (success) {
                        success(dict);
                    }
                    
                }
            }
        });
    }];
    [task resume];
    return task;
}

#pragma mark 获取推荐列表数据
- (NSURLSessionDataTask *)GETBodyTuiJian:(NSString *)url withrequestSerializerContentType:(NSString *)requestSerializerContentType parameters:(id)parameters success:(void (^)(id _Nonnull sucee))success failure:(void (^)(NSError * _Nonnull err))failure {
    
    XSWeakSelf;
    
    
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
        
    /**
     *  可以接受的类型
     */
    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
    [manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Accept"];


    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript", nil];
    
    if(requestSerializerContentType){
        [manager.requestSerializer setValue:requestSerializerContentType forHTTPHeaderField:@"Content-Type"];
    }else{
        [manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
    }
//    [manager.requestSerializer setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
    /**
     *  请求超时的时间
     */
    manager.requestSerializer.timeoutInterval = 100;
    NSString *token = [[NSUserDefaults standardUserDefaults] valueForKey:@"token"];
    if (token) {
        [manager.requestSerializer setValue:token  forHTTPHeaderField:@"Authorization"];
        NSLog(@"API_memberPlaceOrder--用户token==%@\n",token);
    }else{
        if([SSUserManager sharedUser].userModel.tempToken){
            token = [SSUserManager sharedUser].userModel.tempToken;
            NSLog(@"API_memberPlaceOrder--访客token==%@\n",token);
            
            [manager.requestSerializer setValue:token  forHTTPHeaderField:@"Authorization"];
        }
    }
    
    
    
    NSString *finalURL = [API_BASEURL stringByAppendingString:url];
    
            NSMutableString *dataStr = [NSMutableString new];
    NSString *jsonString;
            NSDictionary *parametersData = parameters;
            if(parametersData.allKeys.count>0){
                for (int i = 0; i < parametersData.count;  i ++) {
                    NSString *key = parametersData.allKeys[i];
                    id value = parametersData[key];
                    [dataStr appendFormat:@"%@=%@&",key,value];
                }
                NSString *postStr = [dataStr substringWithRange:NSMakeRange(0, dataStr.length - 1)];
                jsonString = postStr;
            }else{
                jsonString =[NSString new];
            }
    finalURL = [NSString stringWithFormat:@"%@?%@",finalURL,jsonString];
    
    NSLog(@"请求的URL：%@",finalURL);
    NSMutableURLRequest * request = [manager.requestSerializer requestWithMethod:@"GET" URLString:finalURL parameters:parameters error:nil];
    request.HTTPMethod = @"GET";
//    NSString *jsonString;
    if(requestSerializerContentType){
        [request setValue:requestSerializerContentType forHTTPHeaderField:@"Content-Type"];
        
        
//        NSMutableString *dataStr = [NSMutableString new];
//
//        NSDictionary *parametersData = parameters;
//        if(parametersData.allKeys.count>0){
//            for (int i = 0; i < parametersData.count;  i ++) {
//                NSString *key = parametersData.allKeys[i];
//                id value = parametersData[key];
//                [dataStr appendFormat:@"%@=%@&",key,value];
//            }
//            NSString *postStr = [dataStr substringWithRange:NSMakeRange(0, dataStr.length - 1)];
//            jsonString = postStr;
//        }else{
//            jsonString =[NSString new];
//        }
        
    }else{
        [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
        
//        NSData *jsonData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
//        jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
//        if(kStringIsEmpty(jsonString)){
//            jsonString = [NSString new];
//        }
    }
    

//    NSData *jsonData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
//    NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];

//    NSData *bodyData = [jsonString dataUsingEncoding:NSUTF8StringEncoding];
//    if(!bodyData){
//        bodyData = [NSData new];
//    }
//    [request setHTTPBody:bodyData];
    
    NSURLSessionDataTask *task = [manager.session dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
        dispatch_async(dispatch_get_main_queue(), ^{
            if (error !=nil) {
                if (failure) {
                    failure(error);
                }
                
            }else{
                if (data) {
                    NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:nil];
                    [weakSelf successHandling:dict requestUrl:finalURL];
//                    NSLog(@"finalURL===%@\n请求响应：%@",finalURL,dict);
                    if (!dict) {
                        
#warning 暂时注释
#warning 暂时注释
#warning 暂时注释
#warning 暂时注释
//                        [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"token"];
//                        [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"cloudRootNodeID"];
//                        [[NSUserDefaults standardUserDefaults] synchronize];
//                        [[NSNotificationCenter defaultCenter] postNotificationName:@"authorLoginAccess" object:nil];

//                        [ZZMessageHud showMessage:@"登录失效，请重新登录" toView:[UIApplication sharedApplication].windows.firstObject];

                        NSDictionary *eroDict = @{@"code":@"401",@"msg":@"登录失效",@"data":@""};
                        if (success) {
                            success(eroDict);
                        }
                        return;
                    }
                    if (success) {
                        success(dict);
                    }
                    
                }
            }
        });
    }];
    [task resume];
    return task;
}

- (NSURLSessionDataTask *)GETBody:(NSString *)url withrequestSerializerContentType:(NSString *)requestSerializerContentType port:(NSString *)portStr parameters:(id)parameters success:(void (^)(id _Nonnull sucee))success failure:(void (^)(NSError * _Nonnull err))failure {
    
    XSWeakSelf;
    
    
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
        
    /**
     *  可以接受的类型
     */
    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
    [manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Accept"];


    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript", nil];
    
    if(requestSerializerContentType){
        [manager.requestSerializer setValue:requestSerializerContentType forHTTPHeaderField:@"Content-Type"];
    }else{
        [manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
    }
//    [manager.requestSerializer setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
    /**
     *  请求超时的时间
     */
    manager.requestSerializer.timeoutInterval = 100;
    NSString *token = [[NSUserDefaults standardUserDefaults] valueForKey:@"token"];
    if (token) {
        [manager.requestSerializer setValue:token  forHTTPHeaderField:@"Authorization"];
        NSLog(@"API_memberPlaceOrder--用户token==%@\n",token);
    }else{
        if([SSUserManager sharedUser].userModel.tempToken){
            token = [SSUserManager sharedUser].userModel.tempToken;
            NSLog(@"API_memberPlaceOrder--访客token==%@\n",token);
            
            [manager.requestSerializer setValue:token  forHTTPHeaderField:@"Authorization"];
        }
    }
    
    
    NSString *TempFinalURL = [API_BASEURL stringByAppendingString:portStr];
    NSString *finalURL = [NSString stringWithFormat:@"%@%@",TempFinalURL,url];
    NSLog(@"请求的URL：%@",finalURL);
    NSMutableURLRequest * request = [manager.requestSerializer requestWithMethod:@"GET" URLString:finalURL parameters:parameters error:nil];
    request.HTTPMethod = @"GET";
    NSString *jsonString;
    if(requestSerializerContentType){
        [request setValue:requestSerializerContentType forHTTPHeaderField:@"Content-Type"];
        
        
        NSMutableString *dataStr = [NSMutableString new];
       
        NSDictionary *parametersData = parameters;
        if(parametersData.allKeys.count>0){
            for (int i = 0; i < parametersData.count;  i ++) {
                NSString *key = parametersData.allKeys[i];
                id value = parametersData[key];
                [dataStr appendFormat:@"%@=%@&",key,value];
            }
            NSString *postStr = [dataStr substringWithRange:NSMakeRange(0, dataStr.length - 1)];
            jsonString = postStr;
        }else{
            jsonString =[NSString new];
        }
        
    }else{
        [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
        
        NSData *jsonData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
        jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
        if(kStringIsEmpty(jsonString)){
            jsonString = [NSString new];
        }
    }
    

//    NSData *jsonData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
//    NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];

    NSData *bodyData = [jsonString dataUsingEncoding:NSUTF8StringEncoding];
    if(!bodyData){
        bodyData = [NSData new];
    }
    [request setHTTPBody:bodyData];
    
    NSURLSessionDataTask *task = [manager.session dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
        dispatch_async(dispatch_get_main_queue(), ^{
            if (error !=nil) {
                if (failure) {
                    failure(error);
                }
                
            }else{
                if (data) {
                    NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:nil];
                    [weakSelf successHandling:dict requestUrl:finalURL];
//                    NSLog(@"finalURL===%@\n请求响应：%@",finalURL,dict);
                    if (!dict) {
                        
#warning 暂时注释
#warning 暂时注释
#warning 暂时注释
#warning 暂时注释
//                        [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"token"];
//                        [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"cloudRootNodeID"];
//                        [[NSUserDefaults standardUserDefaults] synchronize];
//                        [[NSNotificationCenter defaultCenter] postNotificationName:@"authorLoginAccess" object:nil];

//                        [ZZMessageHud showMessage:@"登录失效，请重新登录" toView:[UIApplication sharedApplication].windows.firstObject];

                        NSDictionary *eroDict = @{@"code":@"401",@"msg":@"登录失效",@"data":@""};
                        if (success) {
                            success(eroDict);
                        }
                        return;
                    }
                    if (success) {
                        success(dict);
                    }
                    
                }
            }
        });
    }];
    [task resume];
    return task;
}

- (NSURLSessionDataTask *)GETBody:(NSString *)url port:(NSString *)portStr withrequestSerializerContentType:(NSString *)requestSerializerContentType parameters:(id)parameters success:(void (^)(id _Nonnull sucee))success failure:(void (^)(NSError * _Nonnull err))failure {
    
    XSWeakSelf;
    
    
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
        
    /**
     *  可以接受的类型
     */
    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
    [manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Accept"];


    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript", nil];
    
    if(requestSerializerContentType){
        [manager.requestSerializer setValue:requestSerializerContentType forHTTPHeaderField:@"Content-Type"];
    }else{
        [manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
    }
//    [manager.requestSerializer setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
    /**
     *  请求超时的时间
     */
    manager.requestSerializer.timeoutInterval = 100;
    NSString *token = [[NSUserDefaults standardUserDefaults] valueForKey:@"token"];
    if (token) {
        [manager.requestSerializer setValue:token  forHTTPHeaderField:@"Authorization"];
        NSLog(@"API_memberPlaceOrder--用户token==%@\n",token);
    }else{
        if([SSUserManager sharedUser].userModel.tempToken){
            token = [SSUserManager sharedUser].userModel.tempToken;
            NSLog(@"API_memberPlaceOrder--访客token==%@\n",token);
            
            [manager.requestSerializer setValue:token  forHTTPHeaderField:@"Authorization"];
        }
    }
    
    
    NSString *TempFinalURL = [API_BASEURL stringByAppendingString:portStr];
    NSString *finalURL = [NSString stringWithFormat:@"%@%@",TempFinalURL,url];
    NSLog(@"请求的URL==%@  token==%@\n",finalURL,token);
    NSMutableURLRequest * request = [manager.requestSerializer requestWithMethod:@"GET" URLString:finalURL parameters:parameters error:nil];
    request.HTTPMethod = @"GET";
    NSString *jsonString;
    if(requestSerializerContentType){
        [request setValue:requestSerializerContentType forHTTPHeaderField:@"Content-Type"];
        
        
        NSMutableString *dataStr = [NSMutableString new];
       
        NSDictionary *parametersData = parameters;
        if(parametersData.allKeys.count>0){
            for (int i = 0; i < parametersData.count;  i ++) {
                NSString *key = parametersData.allKeys[i];
                id value = parametersData[key];
                [dataStr appendFormat:@"%@=%@&",key,value];
            }
            NSString *postStr = [dataStr substringWithRange:NSMakeRange(0, dataStr.length - 1)];
            jsonString = postStr;
        }else{
            jsonString =[NSString new];
        }
        
    }else{
        [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
        
        NSData *jsonData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
        jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
        if(kStringIsEmpty(jsonString)){
            jsonString = [NSString new];
        }
    }
    

//    NSData *jsonData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
//    NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];

//    NSData *bodyData = [jsonString dataUsingEncoding:NSUTF8StringEncoding];
//    if(!bodyData){
//        bodyData = [NSData new];
//    }
//    [request setHTTPBody:bodyData];
    
    NSURLSessionDataTask *task = [manager.session dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
        dispatch_async(dispatch_get_main_queue(), ^{
            if (error !=nil) {
                if (failure) {
                    failure(error);
                }
                
            }else{
                if (data) {
                    NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:nil];
                    [weakSelf successHandling:dict requestUrl:finalURL];
//                    NSLog(@"finalURL===%@\n请求响应：%@",finalURL,dict);
                    if (!dict) {
                        
#warning 暂时注释
#warning 暂时注释
#warning 暂时注释
#warning 暂时注释
//                        [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"token"];
//                        [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"cloudRootNodeID"];
//                        [[NSUserDefaults standardUserDefaults] synchronize];
//                        [[NSNotificationCenter defaultCenter] postNotificationName:@"authorLoginAccess" object:nil];

//                        [ZZMessageHud showMessage:@"登录失效，请重新登录" toView:[UIApplication sharedApplication].windows.firstObject];

                        NSDictionary *eroDict = @{@"code":@"401",@"msg":@"登录失效",@"data":@""};
                        if (success) {
                            success(eroDict);
                        }
                        return;
                    }
                    if (success) {
                        success(dict);
                    }
                    
                }
            }
        });
    }];
    [task resume];
    return task;
}


#pragma mark 成语获取用户信息
- (NSURLSessionDataTask *)GETBodyCYUserInfo:(NSString *)url port:(NSString *)portStr withrequestSerializerContentType:(NSString *)requestSerializerContentType parameters:(id)parameters success:(void (^)(id _Nonnull sucee))success failure:(void (^)(NSError * _Nonnull err))failure {
    
    XSWeakSelf;
    
    
    
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
        
    /**
     *  可以接受的类型
     */
    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
    [manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Accept"];


    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript", nil];
    
    if(requestSerializerContentType){
        [manager.requestSerializer setValue:requestSerializerContentType forHTTPHeaderField:@"Content-Type"];
    }else{
        [manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
    }
//    [manager.requestSerializer setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
    /**
     *  请求超时的时间
     */
    manager.requestSerializer.timeoutInterval = 100;
    NSString *token = [[NSUserDefaults standardUserDefaults] valueForKey:@"token"];
    if (token) {
        [manager.requestSerializer setValue:token  forHTTPHeaderField:@"Authorization"];
        NSLog(@"API_memberPlaceOrder--用户token==%@\n",token);
    }else{
        if([SSUserManager sharedUser].userModel.tempToken){
            token = [SSUserManager sharedUser].userModel.tempToken;
            NSLog(@"API_memberPlaceOrder--访客token==%@\n",token);

            [manager.requestSerializer setValue:token  forHTTPHeaderField:@"Authorization"];
        }
    }
    
    
    NSString *TempFinalURL = [API_BASEURLh5 stringByAppendingString:portStr];
    NSString *finalURL = [NSString stringWithFormat:@"%@%@",TempFinalURL,url];
    NSLog(@"请求的URL：%@",finalURL);
    NSMutableURLRequest * request = [manager.requestSerializer requestWithMethod:@"GET" URLString:finalURL parameters:parameters error:nil];
    request.HTTPMethod = @"GET";
    NSString *jsonString;
    if(requestSerializerContentType){
        [request setValue:requestSerializerContentType forHTTPHeaderField:@"Content-Type"];
        
        
        NSMutableString *dataStr = [NSMutableString new];
       
        NSDictionary *parametersData = parameters;
        if(parametersData.allKeys.count>0){
            for (int i = 0; i < parametersData.count;  i ++) {
                NSString *key = parametersData.allKeys[i];
                id value = parametersData[key];
                [dataStr appendFormat:@"%@=%@&",key,value];
            }
            NSString *postStr = [dataStr substringWithRange:NSMakeRange(0, dataStr.length - 1)];
            jsonString = postStr;
        }else{
            jsonString =[NSString new];
        }
        
    }else{
        [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
        
        NSData *jsonData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
        jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
        if(kStringIsEmpty(jsonString)){
            jsonString = [NSString new];
        }
    }
    

//    NSData *jsonData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
//    NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];

//    NSData *bodyData = [jsonString dataUsingEncoding:NSUTF8StringEncoding];
//    if(!bodyData){
//        bodyData = [NSData new];
//    }
//    [request setHTTPBody:bodyData];
    
    NSURLSessionDataTask *task = [manager.session dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
        dispatch_async(dispatch_get_main_queue(), ^{
            if (error !=nil) {
                if (failure) {
                    failure(error);
                }
                
            }else{
                if (data) {
                    NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:nil];
                    [weakSelf successHandling:dict requestUrl:finalURL];
//                    NSLog(@"finalURL===%@\n请求响应：%@",finalURL,dict);
                    if (!dict) {
                        
#warning 暂时注释
#warning 暂时注释
#warning 暂时注释
#warning 暂时注释
//                        [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"token"];
//                        [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"cloudRootNodeID"];
//                        [[NSUserDefaults standardUserDefaults] synchronize];
//                        [[NSNotificationCenter defaultCenter] postNotificationName:@"authorLoginAccess" object:nil];

//                        [ZZMessageHud showMessage:@"登录失效，请重新登录" toView:[UIApplication sharedApplication].windows.firstObject];

                        NSDictionary *eroDict = @{@"code":@"401",@"msg":@"登录失效",@"data":@""};
                        if (success) {
                            success(eroDict);
                        }
                        return;
                    }
                    if (success) {
                        success(dict);
                    }
                    
                }
            }
        });
    }];
    [task resume];
    return task;
}

- (NSURLSessionDataTask *)POSTBody:(NSString *)url parameters:(id)parameters modelType:(Class)modelType success:(void (^)(id _Nonnull))success failure:(void (^)(NSError * _Nonnull))failure {
    
    XSWeakSelf;
    
    
    return  [self POSTBody:url parameters:parameters success:^(id  _Nonnull responseObject) {
           id modelData = [[modelType class] yy_modelWithJSON:responseObject];
           if (success) {
               success(modelData);
           }
       } failure:^(NSError * _Nonnull error) {
           if (failure) {
               failure(error);
           }
       }];
}


/**
 *  发送post请求
 */
- (void)POSTContentUrl:(NSString *)url
       parameters:(id)parameters
          success:(void (^)(id responseObject))success
          failure:(void (^)(NSError *error))failure {
    
    XSWeakSelf;
    
    
    
    
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
    
    /**
     *  可以接受的类型
     */
    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
    
    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript", nil];
    [manager.requestSerializer setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
    [manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Accept"];

    /**
     *  请求超时的时间
     */
    manager.requestSerializer.timeoutInterval = 100;
    NSString *token = [[NSUserDefaults standardUserDefaults] valueForKey:@"token"];
    NSLog(@"🏃🏃🏃🏃===token==%@\nurl==%@\n",token,url);
    if (token) {
        [manager.requestSerializer setValue:token  forHTTPHeaderField:@"Authorization"];
//        [manager.requestSerializer setValue:token  forHTTPHeaderFieldAction:@"Authorization"];
    }else{
        if([SSUserManager sharedUser].userModel.tempToken){
            token = [SSUserManager sharedUser].userModel.tempToken;
            NSLog(@"API_memberPlaceOrder--访客token==%@\n",token);
            
            [manager.requestSerializer setValue:token  forHTTPHeaderField:@"Authorization"];
        }
    }
    
//    NSDictionary *finalParams = parameters;
    NSString *finalURL = [API_BASEURL stringByAppendingString:url];
    NSMutableString *paramStr = [NSMutableString stringWithString:finalURL];
//    for (NSString *key in finalParams.allKeys) {
//        if ([finalParams.allKeys indexOfObject:key] == 0) {
//            [paramStr appendFormat:@"?%@=%@",key,finalParams[key]];
//        } else {
//            [paramStr appendFormat:@"&%@=%@",key,finalParams[key]];
//        }
//    }
    finalURL = paramStr;
    finalURL = [finalURL stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
    NSLog(@"请求的URL：%@",finalURL);
    

    NSMutableURLRequest * request = [manager.requestSerializer requestWithMethod:@"POST" URLString:finalURL parameters:parameters error:nil];
    NSURLSessionDataTask *task = [manager.session dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
        
        
       dispatch_async(dispatch_get_main_queue(), ^{
           if (error !=nil) {
               if (failure) {
                   failure(error);
               }
           }else{
               if (data) {
                   NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:nil];
                   [weakSelf successHandling:dict requestUrl:finalURL];
                   if(!dict){
                       NSString *tempstr = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
                       
                       NSData *messageData = [tempstr dataUsingEncoding:NSUTF8StringEncoding];
                       dict = [NSJSONSerialization JSONObjectWithData:messageData options:kNilOptions error:nil];
                   }
//                   NSLog(@"finalURL===%@\n请求响应：%@",finalURL,dict);
                   if (!dict) {
                       
                    

//                       if([finalURL containsString:API_duplicatecheckGetDuplicDataByBody]){// 这里是查重提交内容  返回的data是没有数据的
//
//                       }else{
//
//                       }
#warning 暂时注释
#warning 暂时注释
#warning 暂时注释
#warning 暂时注释
//                       [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"token"];
//                       [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"cloudRootNodeID"];
//                       [[NSUserDefaults standardUserDefaults] synchronize];
//
//                       [[NSNotificationCenter defaultCenter] postNotificationName:@"authorLoginAccess" object:nil];
//                       [ZZMessageHud showMessage:@"登录失效，请重新登录" toView:[UIApplication sharedApplication].windows.firstObject];

                       NSDictionary *eroDict = @{@"code":@"401",@"msg":@"登录失效",@"data":@""};
                       if (success) {
                           success(eroDict);
                       }
                       return;
                   }
                   if (success) {
                       success(dict);
                   }
                   
               }
           }
       });
    }];
    [task resume];
    
}



/////pc/toAdvertisement
//- (NSURLSessionDataTask *)POSTPurshaseBody:(NSString *)url parameters:(id)parameters success:(void (^)(id _Nonnull))success failure:(void (^)(NSError * _Nonnull))failure {
//    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
//
//    /**
//     *  可以接受的类型
//     */
//    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
//    [manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Accept"];
//
//
//    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript", nil];
//    [manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
////    [manager.requestSerializer setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
//    /**
//     *  请求超时的时间
//     */
//    manager.requestSerializer.timeoutInterval = 100;
//    NSString *token = [[NSUserDefaults standardUserDefaults] valueForKey:@"token"];
//    if (token) {
//        [manager.requestSerializer setValue:token  forHTTPHeaderField:@"Authorization"];
//    }
//
//    NSString *finalURL = [@"https://p.writemall.com" stringByAppendingString:url];
////    NSLog(@"请求的URL：%@",finalURL);
//    NSMutableURLRequest * request = [manager.requestSerializer requestWithMethod:@"GET" URLString:finalURL parameters:parameters error:nil];
//    NSData *jsonData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
//    NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
//    NSLog(@"\n\njsonString==\n\n%@\n\n",jsonString);
//    NSData *bodyData = [jsonString dataUsingEncoding:NSUTF8StringEncoding];
//    [request setHTTPBody:bodyData];
//    request.HTTPMethod = @"GET";
//    NSURLSessionDataTask *task = [manager.session dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
//        dispatch_async(dispatch_get_main_queue(), ^{
//            if (error !=nil) {
//                if (failure) {
//                    failure(error);
//                }
//
//            }else{
//                if (data) {
//                    NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:nil];
////                    NSLog(@"finalURL===%@\n请求响应：%@",finalURL,dict);
//                    if (!dict) {
//
//#warning 暂时注释
//#warning 暂时注释
//#warning 暂时注释
//#warning 暂时注释
////                        [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"token"];
////                        [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"cloudRootNodeID"];
////                        [[NSUserDefaults standardUserDefaults] synchronize];
////                        [[NSNotificationCenter defaultCenter] postNotificationName:@"authorLoginAccess" object:nil];
//
//                        [ZZMessageHud showMessage:@"登录失效，请重新登录" toView:[UIApplication sharedApplication].windows.firstObject];
//
//                        NSDictionary *eroDict = @{@"code":@"401",@"msg":@"登录失效",@"data":@""};
//                        if (success) {
//                            success(eroDict);
//                        }
//                        return;
//                    }
//                    if (success) {
//                        success(dict);
//                    }
//
//                }
//            }
//        });
//    }];
//    [task resume];
//    return task;
//}
- (NSURLSessionDataTask *)POSTBodyLogin:(NSString *)url withrequestSerializerContentType:(NSString *)requestSerializerContentType parameters:(id)parameters success:(void (^)(id _Nonnull responseObject))success failure:(void (^)(NSError * _Nonnull error))failure {
    
    XSWeakSelf;
    
    
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
        
    /**
     *  可以接受的类型
     */
    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
    [manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Accept"];


    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript", nil];
    
    if(requestSerializerContentType){
        [manager.requestSerializer setValue:requestSerializerContentType forHTTPHeaderField:@"Content-Type"];
    }else{
        [manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
    }
//    [manager.requestSerializer setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
    /**
     *  请求超时的时间
     */
    manager.requestSerializer.timeoutInterval = 100;
//    NSString *token = [[NSUserDefaults standardUserDefaults] valueForKey:@"token"];
//    if (token) {
//        [manager.requestSerializer setValue:token  forHTTPHeaderField:@"Authorization"];
////        NSLog(@"API_memberPlaceOrder--用户token==%@\n",token);
//    }else{
//        if([SSUserManager sharedUser].userModel.tempToken){
//            token = [SSUserManager sharedUser].userModel.tempToken;
////            NSLog(@"API_memberPlaceOrder--访客token==%@\n",token);
//
//            [manager.requestSerializer setValue:token  forHTTPHeaderField:@"Authorization"];
//        }
//        else{
//            [manager.requestSerializer setValue:@"Basic Y2xpZW50LWFwOjFxYXp4c3cy"  forHTTPHeaderField:@"Authorization"];
//        }
//    }
    [manager.requestSerializer setValue:@"Basic Y2xpZW50LWFwOjFxYXp4c3cy"  forHTTPHeaderField:@"Authorization"];
    
    
    NSString *finalURL = [API_BASEURL stringByAppendingString:url];
    NSLog(@"请求的URL：%@",finalURL);
    NSMutableURLRequest * request = [manager.requestSerializer requestWithMethod:@"POST" URLString:finalURL parameters:parameters error:nil];
    
    NSString *jsonString;
    if(requestSerializerContentType){
        [request setValue:requestSerializerContentType forHTTPHeaderField:@"Content-Type"];
        
        
        NSMutableString *dataStr = [NSMutableString new];
       
        NSDictionary *parametersData = parameters;
        if(parametersData.allKeys.count>0){
            for (int i = 0; i < parametersData.count;  i ++) {
                NSString *key = parametersData.allKeys[i];
                id value = parametersData[key];
                [dataStr appendFormat:@"%@=%@&",key,value];
            }
            NSString *postStr = [dataStr substringWithRange:NSMakeRange(0, dataStr.length - 1)];
            jsonString = postStr;
        }else{
            jsonString =[NSString new];
        }
        
    }else{
        [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
        
        NSData *jsonData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
        jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
        if(kStringIsEmpty(jsonString)){
            jsonString = [NSString new];
        }
    }
    

//    NSData *jsonData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
//    NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];

    NSData *bodyData = [jsonString dataUsingEncoding:NSUTF8StringEncoding];
    if(!bodyData){
        bodyData = [NSData new];
    }
    [request setHTTPBody:bodyData];
    
    NSURLSessionDataTask *task = [manager.session dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
        dispatch_async(dispatch_get_main_queue(), ^{
            if (error !=nil) {
                if (failure) {
                    failure(error);
                }
                
            }else{
                if (data) {
                    NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:nil];
                    [weakSelf successHandling:dict requestUrl:finalURL];
//                    NSLog(@"finalURL===%@\n请求响应：%@",finalURL,dict);
                    if (!dict) {
                        
#warning 暂时注释
#warning 暂时注释
#warning 暂时注释
#warning 暂时注释
//                        [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"token"];
//                        [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"cloudRootNodeID"];
//                        [[NSUserDefaults standardUserDefaults] synchronize];
//                        [[NSNotificationCenter defaultCenter] postNotificationName:@"authorLoginAccess" object:nil];

//                        [ZZMessageHud showMessage:@"登录失效，请重新登录" toView:[UIApplication sharedApplication].windows.firstObject];

                        NSDictionary *eroDict = @{@"code":@"401",@"msg":@"登录失效",@"data":@""};
                        if (success) {
                            success(eroDict);
                        }
                        return;
                    }
                    if (success) {
                        success(dict);
                    }
                    
                }
            }
        });
    }];
    [task resume];
    return task;
}
- (NSURLSessionDataTask *)POSTBodyLoginRegister22:(NSString *)url withrequestSerializerContentType:(NSString *)requestSerializerContentType port:(NSString *)portStr parameters:(id)parametersDict success:(void (^)(id _Nonnull responseObject))success failure:(void (^)(NSError * _Nonnull error))failure{
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
        
    
    NSLog(@"POSTBodyLoginRegister--parametersDict==%@\n",parametersDict);
    /**
     *  可以接受的类型
     */
    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
    [manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Accept"];


    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript", nil];
    
    if(requestSerializerContentType){
        [manager.requestSerializer setValue:requestSerializerContentType forHTTPHeaderField:@"Content-Type"];
    }else{
        [manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
    }
//    [manager.requestSerializer setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
    /**
     *  请求超时的时间
     */
    manager.requestSerializer.timeoutInterval = 100;
    [manager.requestSerializer setValue:@"Basic Y2xpZW50LWFwOjFxYXp4c3cy"  forHTTPHeaderField:@"Authorization"];

    
    
    NSString *tempString = [NSString stringWithFormat:@"%@%@",touristsRegister_BASEURL,portStr];
    NSString *finalURL = [tempString stringByAppendingString:url];
//    finalURL = [NSString stringWithFormat:@"%@?%@",finalURL,jsonString2];
    
    
    NSLog(@"请求的URL：%@",finalURL);
    NSMutableURLRequest * request = [manager.requestSerializer requestWithMethod:@"POST" URLString:finalURL parameters:parametersDict error:nil];
    request.HTTPMethod = @"POST";
    NSString *jsonString;
    if(requestSerializerContentType){
        [request setValue:requestSerializerContentType forHTTPHeaderField:@"Content-Type"];

        NSData *jsonData = [NSJSONSerialization dataWithJSONObject:parametersDict options:0 error:nil];
        jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
        
    }else{
        [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
        
        NSData *jsonData = [NSJSONSerialization dataWithJSONObject:parametersDict options:0 error:nil];
        jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
        if(kStringIsEmpty(jsonString)){
            jsonString = [NSString new];
        }
    }
    

    NSData *bodyData = [jsonString dataUsingEncoding:NSUTF8StringEncoding];
    if(!bodyData){
        bodyData = [NSData new];
    }
    [request setHTTPBody:bodyData];
    XSWeakSelf;
    NSURLSessionDataTask *task = [manager.session dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
        dispatch_async(dispatch_get_main_queue(), ^{
            if (error !=nil) {
                if (failure) {
                    failure(error);
                }
                
            }else{
                if (data) {
                    NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:nil];
                    [weakSelf successHandling:dict requestUrl:finalURL];
                    NSLog(@"response===%@\n",response);
                    if (!dict) {
                        
#warning 暂时注释
#warning 暂时注释
#warning 暂时注释
#warning 暂时注释
//                        [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"token"];
//                        [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"cloudRootNodeID"];
//                        [[NSUserDefaults standardUserDefaults] synchronize];
//                        [[NSNotificationCenter defaultCenter] postNotificationName:@"authorLoginAccess" object:nil];

//                        [ZZMessageHud showMessage:@"登录失效，请重新登录" toView:[UIApplication sharedApplication].windows.firstObject];

                        NSDictionary *eroDict = @{@"code":@"401",@"msg":@"登录失效",@"data":@""};
                        if (success) {
                            success(eroDict);
                        }
                        return;
                    }
                    if (success) {
                        success(dict);
                    }
                    
                }
            }
        });
    }];
    [task resume];
    return task;
}
- (NSURLSessionDataTask *)POSTBodyLoginRegister:(NSString *)url withrequestSerializerContentType:(NSString *)requestSerializerContentType port:(NSString *)portStr parameters:(id)parametersDict success:(void (^)(id _Nonnull responseObject))success failure:(void (^)(NSError * _Nonnull error))failure {
    
    XSWeakSelf;
    
    
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
        
    
    NSLog(@"POSTBodyLoginRegister--parametersDict==%@\n",parametersDict);
    /**
     *  可以接受的类型
     */
    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
    [manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Accept"];


    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript", nil];
    
    if(requestSerializerContentType){
        [manager.requestSerializer setValue:requestSerializerContentType forHTTPHeaderField:@"Content-Type"];
    }else{
        [manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
    }
//    [manager.requestSerializer setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
    /**
     *  请求超时的时间
     */
    manager.requestSerializer.timeoutInterval = 100;
//    NSString *token = [[NSUserDefaults standardUserDefaults] valueForKey:@"token"];
//    if (token) {
//        [manager.requestSerializer setValue:token  forHTTPHeaderField:@"Authorization"];
////        NSLog(@"API_memberPlaceOrder--用户token==%@\n",token);
//    }else{
//        if([SSUserManager sharedUser].userModel.tempToken){
//            token = [SSUserManager sharedUser].userModel.tempToken;
////            NSLog(@"API_memberPlaceOrder--访客token==%@\n",token);
//
//            [manager.requestSerializer setValue:token  forHTTPHeaderField:@"Authorization"];
//        }
//        else{
//            [manager.requestSerializer setValue:@"Basic Y2xpZW50LWFwOjFxYXp4c3cy"  forHTTPHeaderField:@"Authorization"];
//        }
//    }
    [manager.requestSerializer setValue:@"Basic Y2xpZW50LWFwOjFxYXp4c3cy"  forHTTPHeaderField:@"Authorization"];

    
   
    
    
    NSString *jsonString2;
    if(requestSerializerContentType){
        NSMutableString *dataStr2 = [NSMutableString new];
        NSDictionary *parametersData = parametersDict;
        if(parametersData.allKeys.count>0){
            for (int i = 0; i < parametersData.count;  i ++) {
                NSString *key = parametersData.allKeys[i];
                id value = parametersData[key];
                [dataStr2 appendFormat:@"%@=%@&",key,value];
            }
            NSString *postStr2 = [dataStr2 substringWithRange:NSMakeRange(0, dataStr2.length - 1)];
            jsonString2 = postStr2;
        }else{
            jsonString2 =[NSString new];
        }
    }else{
        NSData *jsonData2 = [NSJSONSerialization dataWithJSONObject:parametersDict options:0 error:nil];
        jsonString2 = [[NSString alloc] initWithData:jsonData2 encoding:NSUTF8StringEncoding];
        if(kStringIsEmpty(jsonString2)){
            jsonString2 = [NSString new];
        }
    }
    
    
//    NSString *tempString = [NSString stringWithFormat:@"%@%@",touristsRegister_BASEURL,portStr];
    NSString *finalURL = url;//[tempString stringByAppendingString:url];
    finalURL = [NSString stringWithFormat:@"%@?%@",finalURL,jsonString2];
    
    
    NSLog(@"请求的URL：%@",finalURL);
    NSMutableURLRequest * request = [manager.requestSerializer requestWithMethod:@"POST" URLString:finalURL parameters:parametersDict error:nil];
    request.HTTPMethod = @"POST";
    NSString *jsonString;
    if(requestSerializerContentType){
        [request setValue:requestSerializerContentType forHTTPHeaderField:@"Content-Type"];
        
        
//        NSMutableString *dataStr = [NSMutableString new];
//
//        NSDictionary *parametersData = parametersDict;
//        if(parametersData.allKeys.count>0){
//            for (int i = 0; i < parametersData.count;  i ++) {
//                NSString *key = parametersData.allKeys[i];
//                id value = parametersData[key];
//                [dataStr appendFormat:@"%@=%@&",key,value];
//            }
//            NSString *postStr = [dataStr substringWithRange:NSMakeRange(0, dataStr.length - 1)];
//            jsonString = postStr;
//        }else{
//            jsonString =[NSString new];
//        }
        jsonString = [NSString convertToJsonData:parametersDict];
    }else{
        [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
        
        NSData *jsonData = [NSJSONSerialization dataWithJSONObject:parametersDict options:0 error:nil];
        jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
        if(kStringIsEmpty(jsonString)){
            jsonString = [NSString new];
        }
    }
    

//    NSData *jsonData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
//    NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];

    NSData *bodyData = [jsonString dataUsingEncoding:NSUTF8StringEncoding];
    if(!bodyData){
        bodyData = [NSData new];
    }
    [request setHTTPBody:bodyData];
    
    NSURLSessionDataTask *task = [manager.session dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
        dispatch_async(dispatch_get_main_queue(), ^{
            if (error !=nil) {
                if (failure) {
                    failure(error);
                }
                
            }else{
                if (data) {
                    NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:nil];
                    [weakSelf successHandling:dict requestUrl:finalURL];
                    NSLog(@"response===%@\n",response);
                    if (!dict) {
                        
#warning 暂时注释
#warning 暂时注释
#warning 暂时注释
#warning 暂时注释
//                        [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"token"];
//                        [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"cloudRootNodeID"];
//                        [[NSUserDefaults standardUserDefaults] synchronize];
//                        [[NSNotificationCenter defaultCenter] postNotificationName:@"authorLoginAccess" object:nil];

//                        [ZZMessageHud showMessage:@"登录失效，请重新登录" toView:[UIApplication sharedApplication].windows.firstObject];

                        NSDictionary *eroDict = @{@"code":@"401",@"msg":@"登录失效",@"data":@""};
                        if (success) {
                            success(eroDict);
                        }
                        return;
                    }
                    if (success) {
                        success(dict);
                    }
                    
                }
            }
        });
    }];
    [task resume];
    return task;
}



- (NSURLSessionDataTask *)POSTBody:(NSString *)url port:(NSString *)portStr parameters:(id)parameters success:(void (^)(id _Nonnull responseObject))success failure:(void (^)(NSError * _Nonnull error))failure {
    
    XSWeakSelf;
    
    
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
        
    /**
     *  可以接受的类型
     */
    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
    [manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Accept"];


    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript", nil];
    [manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
//    [manager.requestSerializer setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
    
    
    
    
    /**
     *  请求超时的时间
     */
    manager.requestSerializer.timeoutInterval = 100;
    NSString *token = [[NSUserDefaults standardUserDefaults] valueForKey:@"token"];
    if (token) {
        [manager.requestSerializer setValue:token  forHTTPHeaderField:@"Authorization"];
    }else{
        if([SSUserManager sharedUser].userModel.tempToken){
            token = [SSUserManager sharedUser].userModel.tempToken;
            NSLog(@"API_memberPlaceOrder--访客token==%@\n",token);
            
            [manager.requestSerializer setValue:token  forHTTPHeaderField:@"Authorization"];
        }else{
            
            [manager.requestSerializer setValue:@"Basic Y2xpZW50LWFwOjFxYXp4c3cy" forHTTPHeaderField:@"Authorization"];
        }
    }
    
//    NSString *finalURL = [API_BASEURL stringByAppendingString:url];
//    NSLog(@"请求的URL：%@",finalURL);
    NSString *TempFinalURL = [API_BASEURL stringByAppendingString:portStr];
    NSString *finalURL = [NSString stringWithFormat:@"%@%@",TempFinalURL,url];
    NSLog(@"请求的URL：%@",finalURL);
    
    NSMutableURLRequest * request = [manager.requestSerializer requestWithMethod:@"POST" URLString:finalURL parameters:parameters error:nil];
    NSData *jsonData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
    NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
    NSLog(@"\n\njsonString==\n\n%@\n\n",jsonString);
    NSData *bodyData = [jsonString dataUsingEncoding:NSUTF8StringEncoding];
    [request setHTTPBody:bodyData];
    request.HTTPMethod = @"POST";
    NSURLSessionDataTask *task = [manager.session dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
        
        NSLog(@"request--URL：%@",finalURL);
        dispatch_async(dispatch_get_main_queue(), ^{
            if (error !=nil) {
                if (failure) {
                    failure(error);
                }
                
            }else{
                
//                NSDictionary *dict22 = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:nil];
                
                
//                if (data) {
//                    NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:nil];
////                    NSLog(@"finalURL===%@\n请求响应：%@",finalURL,dict);
//                    if (!dict) {
                NSDictionary *tempDictData;
                        if (data) {
                            NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:nil];
                            [weakSelf successHandling:dict requestUrl:finalURL];
        //                    NSLog(@"finalURL===%@\n请求响应：%@",finalURL,dict);
                            if (dict) {
                                tempDictData = dict;
                            }
                            
                        }
                        
                        NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)response;
                        if(httpResponse.statusCode==200){
                            if (success) {
                                
                                if(tempDictData){
                                    success(@{@"message":@"成功",@"data":tempDictData,@"code":@"200"});
                                }else{
                                    success(@{@"message":@"成功",@"data":@"null",@"code":@"200"});
                                }
                            }
                        }
                        else{
                            
    #warning 暂时注释
    #warning 暂时注释
    #warning 暂时注释
    #warning 暂时注释
    //                        [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"token"];
    //                        [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"cloudRootNodeID"];
    //                        [[NSUserDefaults standardUserDefaults] synchronize];
    //                        [[NSNotificationCenter defaultCenter] postNotificationName:@"authorLoginAccess" object:nil];

//                            [ZZMessageHud showMessage:@"登录失效，请重新登录" toView:[UIApplication sharedApplication].windows.firstObject];
                            
                            NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)response;
                            if(httpResponse.statusCode==500){
                                NSDictionary *eroDict = @{@"code":@"500",@"msg":@"系统繁忙",@"data":@""};
                                if (success) {
                                    success(eroDict);
                                }
                                return;
                            }
                            else{
                                NSDictionary *eroDict = @{@"code":@"401",@"msg":@"登录失效",@"data":@""};
                                if (success) {
                                    success(eroDict);
                                }
                                return;
                            }

                            
                        }
//                    }
//                    if (success) {
//                        success(dict);
//                    }
//
//                }
            }
        });
    }];
    [task resume];
    return task;
}


/**
 *  发送Put请求
 */
- (void)PutContentUrl:(NSString *)url
                 Port:(NSString *)portStr
       parameters:(id)parameters
          success:(void (^)(id responseObject))success
          failure:(void (^)(NSError *error))failure{
    
    
    NSString *TempFinalURL = [API_BASEURL stringByAppendingString:portStr];
    NSString *finalURL = [TempFinalURL stringByAppendingString:url];
    NSMutableString *paramStr = [NSMutableString stringWithString:finalURL];
    
    
    NSURL *requestUrl = [NSURL URLWithString:paramStr];
    NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:requestUrl];
    request.HTTPMethod = @"PUT";
    
    
    NSString *token = [[NSUserDefaults standardUserDefaults] valueForKey:@"token"];
    NSLog(@"🏃🏃🏃🏃===token==%@\nfinalURL==%@\n",token,finalURL);
    if (token) {
        
        request.allHTTPHeaderFields = @{@"Content-Type":@"application/json",@"Authorization":token};//此处为请求头，类型为字典
    }else{
        if([SSUserManager sharedUser].userModel.tempToken){
            token = [SSUserManager sharedUser].userModel.tempToken;
            NSLog(@"API_memberPlaceOrder--访客token==%@\n",token);

            
            
            request.allHTTPHeaderFields = @{@"Content-Type":@"application/json",@"Authorization":token};//此处为请求头，类型为字典
        }
    }
    
    NSData *jsonData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
    NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
    XSWeakSelf;
    NSString *msg = jsonString;//@"请求参数";
    NSData *data = [msg dataUsingEncoding:NSUTF8StringEncoding];
    request.HTTPBody = data;
    [[[NSURLSession sharedSession] dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {

        NSLog(@"%@---%@",url,[[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]);
            NSLog(@"url--error.description==%@\n",error.description);
        
        dispatch_async(dispatch_get_main_queue(), ^{
            if (error !=nil) {
                if (failure) {
                    failure(error);
                }
                
            }else{
                if (data) {
                    NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:nil];
                    [weakSelf successHandling:dict requestUrl:finalURL];
    //                    NSLog(@"finalURL===%@\n请求响应：%@",finalURL,dict);
                    if (!dict) {
                        
    #warning 暂时注释
    #warning 暂时注释
    #warning 暂时注释
    #warning 暂时注释
    //                        [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"token"];
    //                        [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"cloudRootNodeID"];
    //                        [[NSUserDefaults standardUserDefaults] synchronize];
    //                        [[NSNotificationCenter defaultCenter] postNotificationName:@"authorLoginAccess" object:nil];

//                        [ZZMessageHud showMessage:@"登录失效，请重新登录" toView:[UIApplication sharedApplication].windows.firstObject];

                        NSDictionary *eroDict = @{@"code":@"401",@"msg":@"登录失效",@"data":@""};
                        if (success) {
                            success(eroDict);
                        }
                        return;
                    }
                    if (success) {
                        success(dict);
                    }
                    
                }
            }
        });
    }] resume];
}


- (NSURLSessionDataTask *)POSTBody:(NSString *)url Port:(NSString *)portStr withrequestSerializerContentType:(NSString *)requestSerializerContentType parameters:(id)parameters success:(void (^)(id _Nonnull responseObject))success failure:(void (^)(NSError * _Nonnull error))failure {
    
    XSWeakSelf;
    
    
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
        
    /**
     *  可以接受的类型
     */
    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
    [manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Accept"];


    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript", nil];
    
    if(requestSerializerContentType){
        [manager.requestSerializer setValue:requestSerializerContentType forHTTPHeaderField:@"Content-Type"];
    }else{
        [manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
    }
//    [manager.requestSerializer setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
    /**
     *  请求超时的时间
     */
    manager.requestSerializer.timeoutInterval = 100;
    NSString *token = [[NSUserDefaults standardUserDefaults] valueForKey:@"token"];
    if (token) {
        [manager.requestSerializer setValue:token  forHTTPHeaderField:@"Authorization"];
//        NSLog(@"API_memberPlaceOrder--用户token==%@\n",token);
    }else{
        if([SSUserManager sharedUser].userModel.tempToken){
            token = [SSUserManager sharedUser].userModel.tempToken;
//            NSLog(@"API_memberPlaceOrder--访客token==%@\n",token);
            
            [manager.requestSerializer setValue:token  forHTTPHeaderField:@"Authorization"];
        }
        else{
            [manager.requestSerializer setValue:@"Basic Y2xpZW50LWFwOjFxYXp4c3cy"  forHTTPHeaderField:@"Authorization"];
        }
    }
    
    
    
//    NSString *finalURL = [API_BASEURL stringByAppendingString:url];
//    NSLog(@"请求的URL：%@",finalURL);
    
    NSString *TempFinalURL = [API_BASEURL stringByAppendingString:portStr];
    NSString *finalURL = [NSString stringWithFormat:@"%@%@",TempFinalURL,url];
    NSLog(@"请求的URL：%@",finalURL);
    
    NSMutableURLRequest * request = [manager.requestSerializer requestWithMethod:@"POST" URLString:finalURL parameters:parameters error:nil];
    
    NSString *jsonString;
    if(requestSerializerContentType){
        [request setValue:requestSerializerContentType forHTTPHeaderField:@"Content-Type"];
        
        
        NSMutableString *dataStr = [NSMutableString new];
       
        NSDictionary *parametersData = parameters;
        if(parametersData.allKeys.count>0){
            for (int i = 0; i < parametersData.count;  i ++) {
                NSString *key = parametersData.allKeys[i];
                id value = parametersData[key];
                [dataStr appendFormat:@"%@=%@&",key,value];
            }
            NSString *postStr = [dataStr substringWithRange:NSMakeRange(0, dataStr.length - 1)];
            jsonString = postStr;
        }else{
            jsonString =[NSString new];
        }
        
    }else{
        [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
        
        NSData *jsonData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
        jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
        if(kStringIsEmpty(jsonString)){
            jsonString = [NSString new];
        }
    }
    

//    NSData *jsonData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
//    NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];

    NSData *bodyData = [jsonString dataUsingEncoding:NSUTF8StringEncoding];
    if(!bodyData){
        bodyData = [NSData new];
    }
    [request setHTTPBody:bodyData];
    
    NSURLSessionDataTask *task = [manager.session dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
        dispatch_async(dispatch_get_main_queue(), ^{
            if (error !=nil) {
                if (failure) {
                    failure(error);
                }
                
            }else{
                if (data) {
                    NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:nil];
                    [weakSelf successHandling:dict requestUrl:finalURL];
//                    NSLog(@"finalURL===%@\n请求响应：%@",finalURL,dict);
                    if (!dict) {
                        
#warning 暂时注释
#warning 暂时注释
#warning 暂时注释
#warning 暂时注释
//                        [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"token"];
//                        [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"cloudRootNodeID"];
//                        [[NSUserDefaults standardUserDefaults] synchronize];
//                        [[NSNotificationCenter defaultCenter] postNotificationName:@"authorLoginAccess" object:nil];

//                        [ZZMessageHud showMessage:@"登录失效，请重新登录" toView:[UIApplication sharedApplication].windows.firstObject];

                        NSDictionary *eroDict = @{@"code":@"401",@"msg":@"登录失效",@"data":@""};
                        if (success) {
                            success(eroDict);
                        }
                        return;
                    }
                    if (success) {
                        success(dict);
                    }
                    
                }
            }
        });
    }];
    [task resume];
    return task;
}



- (void)uploadImageWithUrl:(NSString *)URLStr  Port:(NSString *)portStr withrequestSerializerContentType:(NSString *)requestSerializerContentType  withImagesArray:(NSArray *)images withParame:(NSDictionary *)parameDict success:(void (^)(id _Nonnull responseObject))success progress:(nullable void (^)(NSProgress * _Nonnull))uploadProgre failure:(void (^)(NSError * _Nonnull error))failure {
    
    XSWeakSelf;
    
    
    
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
        
    /**
     *  可以接受的类型
     */
    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
    [manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Accept"];


    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript", nil];
    
    if(requestSerializerContentType){
        [manager.requestSerializer setValue:requestSerializerContentType forHTTPHeaderField:@"Content-Type"];
    }else{
        [manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
    }
//    [manager.requestSerializer setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
    /**
     *  请求超时的时间
     */
    manager.requestSerializer.timeoutInterval = 100;
    NSString *token = [[NSUserDefaults standardUserDefaults] valueForKey:@"token"];
    if (token) {
        [manager.requestSerializer setValue:token  forHTTPHeaderField:@"Authorization"];
//        NSLog(@"API_memberPlaceOrder--用户token==%@\n",token);
    }else{
        if([SSUserManager sharedUser].userModel.tempToken){
            token = [SSUserManager sharedUser].userModel.tempToken;
//            NSLog(@"API_memberPlaceOrder--访客token==%@\n",token);
            
            [manager.requestSerializer setValue:token  forHTTPHeaderField:@"Authorization"];
        }
        else{
            [manager.requestSerializer setValue:@"Basic Y2xpZW50LWFwOjFxYXp4c3cy"  forHTTPHeaderField:@"Authorization"];
        }
    }
    
    
    
//    NSString *finalURL = [API_BASEURL stringByAppendingString:url];
//    NSLog(@"请求的URL：%@",finalURL);
    
    NSString *TempFinalURL = [API_BASEURL stringByAppendingString:portStr];
    NSString *finalURL = [NSString stringWithFormat:@"%@%@",TempFinalURL,URLStr];
    NSLog(@"请求的URL：%@",finalURL);
    
    [manager POST:finalURL parameters:parameDict headers:@{} constructingBodyWithBlock:^(id<AFMultipartFormData>  _Nonnull formData) {
        for (int i=0; i<images.count; i++) {
            UIImage *tpImg = images[i];
            NSData *imgData = UIImagePNGRepresentation(tpImg);
            NSDateFormatter *formatter =[[NSDateFormatter alloc] init];
            [formatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
            NSString *dString = [formatter stringFromDate:[NSDate date]];

            NSString *fileNameStr = [NSString stringWithFormat:@"file%d%@",i,dString];
            [formData appendPartWithFileData:imgData name:@"files" fileName:fileNameStr mimeType:@"image/png"];
        }

    } progress:^(NSProgress * _Nonnull uploadProgress) {
        
    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        [weakSelf successHandling:responseObject requestUrl:finalURL];
        success(responseObject);
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        failure(error);
    }];
    
}
#pragma mark 触发推荐
- (void)postRecommendListWithUrl:(NSString *)URLStr  Port:(NSString *)portStr withrequestSerializerContentType:(NSString *)requestSerializerContentType  withImagesArray:(NSArray *)images withParame:(NSDictionary *)parameDict success:(void (^)(id _Nonnull responseObject))success progress:(nullable void (^)(NSProgress * _Nonnull))uploadProgre failure:(void (^)(NSError * _Nonnull error))failure {
    
    XSWeakSelf;
    
    
    
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
        
    /**
     *  可以接受的类型
     */
    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
    [manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Accept"];


    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript", nil];
    
    if(requestSerializerContentType){
        [manager.requestSerializer setValue:requestSerializerContentType forHTTPHeaderField:@"Content-Type"];
    }else{
        [manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
    }
//    [manager.requestSerializer setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
    /**
     *  请求超时的时间
     */
    manager.requestSerializer.timeoutInterval = 100;
    NSString *token = [[NSUserDefaults standardUserDefaults] valueForKey:@"token"];
    if (token) {
        [manager.requestSerializer setValue:token  forHTTPHeaderField:@"Authorization"];
//        NSLog(@"API_memberPlaceOrder--用户token==%@\n",token);
    }else{
        if([SSUserManager sharedUser].userModel.tempToken){
            token = [SSUserManager sharedUser].userModel.tempToken;
//            NSLog(@"API_memberPlaceOrder--访客token==%@\n",token);
            
            [manager.requestSerializer setValue:token  forHTTPHeaderField:@"Authorization"];
        }
        else{
            [manager.requestSerializer setValue:@"Basic Y2xpZW50LWFwOjFxYXp4c3cy"  forHTTPHeaderField:@"Authorization"];
        }
    }
    
    
    
//    NSString *finalURL = [API_BASEURL stringByAppendingString:url];
//    NSLog(@"请求的URL：%@",finalURL);
    
    NSString *TempFinalURL = [API_BASEURL stringByAppendingString:portStr];
    NSString *finalURL = [NSString stringWithFormat:@"%@%@",TempFinalURL,URLStr];
    NSLog(@"请求的URL：%@",finalURL);
    
    
    [manager POST:finalURL parameters:parameDict headers:@{@"Authorization":token} constructingBodyWithBlock:^(id<AFMultipartFormData>  _Nonnull formData) {
        for (int i=0; i<images.count; i++) {
//            UIImage *tpImg = images[i];
            NSData *imgData = [@"tempStr" dataUsingEncoding:NSUTF8StringEncoding];//[NSData new];//UIImagePNGRepresentation(tpImg);
            NSDateFormatter *formatter =[[NSDateFormatter alloc] init];
            [formatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
            NSString *dString = [formatter stringFromDate:[NSDate date]];

            NSString *fileNameStr = [NSString stringWithFormat:@"file%d%@",i,dString];
            [formData appendPartWithFileData:imgData name:@"files" fileName:fileNameStr mimeType:@"image/png"];
        }

    } progress:^(NSProgress * _Nonnull uploadProgress) {
        
    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        [weakSelf successHandling:responseObject requestUrl:finalURL];
        success(responseObject);
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        failure(error);
    }];
    
}
//MimeTyp
//超文本标记语言文本.html text/html
//
//xml文档.xml text/xml
//
//XHTML文档.xhtml application/xhtml+xml
//
//普通文本.txt text/plain
//
//RTF文本.rtf application/rtf
//
//PDF文档.pdf application/pdf
//
//Microsoft Word文件.word application/msword
//
//PNG图像.png image/png
//
//GIF图形.gif image/gif
//
//JPEG图形.jpeg,.jpg image/jpeg
//
//au声音文件.au audio/basic
//
//MIDI音乐文件mid,.midi audio/midi,audio/x-midi
//
//RealAudio音乐文件.ra, .ram audio/x-pn-realaudio
//
//MPEG文件.mpg,.mpeg video/mpeg
//
//AVI文件.avi video/x-msvideo
//
//GZIP文件.gz application/x-gzip
//
//TAR文件.tar application/x-tar
//
//任意的二进制数据application/octet-stream
//
- (void)uploadFileWithUrl:(NSString *)URLStr Port:(NSString *)portStr withrequestSerializerContentType:(NSString *)requestSerializerContentType  withFileData:(NSData *)fData withFileName:(NSString *)fileNameStr withMimeType:(NSString *)mimeTypeStr withParame:(NSDictionary *)parameDict success:(void (^)(id _Nonnull responseObject))success progress:(nullable void (^)(NSProgress * _Nonnull))uploadProgre failure:(void (^)(NSError * _Nonnull error))failure {
    
    XSWeakSelf;
    
    
    
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
        
    /**
     *  可以接受的类型
     */
    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
    [manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Accept"];


    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript", nil];
    
    if(requestSerializerContentType){
        [manager.requestSerializer setValue:requestSerializerContentType forHTTPHeaderField:@"Content-Type"];
    }else{
        [manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
    }
//    [manager.requestSerializer setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
    /**
     *  请求超时的时间
     */
    manager.requestSerializer.timeoutInterval = 100;
    NSString *token = [[NSUserDefaults standardUserDefaults] valueForKey:@"token"];
    if (token) {
        [manager.requestSerializer setValue:token  forHTTPHeaderField:@"Authorization"];
//        NSLog(@"API_memberPlaceOrder--用户token==%@\n",token);
    }else{
        if([SSUserManager sharedUser].userModel.tempToken){
            token = [SSUserManager sharedUser].userModel.tempToken;
//            NSLog(@"API_memberPlaceOrder--访客token==%@\n",token);
            
            [manager.requestSerializer setValue:token  forHTTPHeaderField:@"Authorization"];
        }
        else{
            [manager.requestSerializer setValue:@"Basic Y2xpZW50LWFwOjFxYXp4c3cy"  forHTTPHeaderField:@"Authorization"];
        }
    }
    
    
    
//    NSString *finalURL = [API_BASEURL stringByAppendingString:url];
//    NSLog(@"请求的URL：%@",finalURL);
    
    NSString *TempFinalURL = [API_BASEURL stringByAppendingString:portStr];
    NSString *finalURL = [NSString stringWithFormat:@"%@%@",TempFinalURL,URLStr];
    NSLog(@"请求的URL：%@",finalURL);
    
    if(mimeTypeStr==nil||mimeTypeStr.length==0){
        mimeTypeStr = @"image/png";
    }
//    [manager POST:finalURL parameters:parameDict constructingBodyWithBlock:^(id<AFMultipartFormData>  _Nonnull formData) {
//
//        [formData appendPartWithFileData:fData name:@"upfile" fileName:fileNameStr mimeType:mimeTypeStr];
//        int a =  10;
//        } progress:^(NSProgress * _Nonnull uploadProgress) {
//            uploadProgre(uploadProgress);
//        } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
//            success(responseObject);
//        } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
//            failure(error);
//        }];
    [manager POST:finalURL parameters:parameDict headers:@{} constructingBodyWithBlock:^(id<AFMultipartFormData>  _Nonnull formData) {
        [formData appendPartWithFileData:fData name:@"upfile" fileName:fileNameStr mimeType:mimeTypeStr];
    } progress:^(NSProgress * _Nonnull uploadProgress) {
        uploadProgre(uploadProgress);
    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        
        success(responseObject);
        [weakSelf successHandling:responseObject requestUrl:finalURL];
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        failure(error);
    }];
}

//MimeTyp
//超文本标记语言文本.html text/html
//
//xml文档.xml text/xml
//
//XHTML文档.xhtml application/xhtml+xml
//
//普通文本.txt text/plain
//
//RTF文本.rtf application/rtf
//
//PDF文档.pdf application/pdf
//
//Microsoft Word文件.word application/msword
//
//PNG图像.png image/png
//
//GIF图形.gif image/gif
//
//JPEG图形.jpeg,.jpg image/jpeg
//
//au声音文件.au audio/basic
//
//MIDI音乐文件mid,.midi audio/midi,audio/x-midi
//
//RealAudio音乐文件.ra, .ram audio/x-pn-realaudio
//
//MPEG文件.mpg,.mpeg video/mpeg
//
//AVI文件.avi video/x-msvideo
//
//GZIP文件.gz application/x-gzip
//
//TAR文件.tar application/x-tar
//
//任意的二进制数据application/octet-stream
//
- (void)uploadFileWithUrl:(NSString *)URLStr Port:(NSString *)portStr withrequestSerializerContentType:(NSString *)requestSerializerContentType  withFileData:(NSData *)fData withFileName:(NSString *)fileNameStr withServerField:(NSString *)Field withMimeType:(NSString *)mimeTypeStr withParame:(NSDictionary *)parameDict success:(void (^)(id _Nonnull responseObject))success progress:(nullable void (^)(NSProgress * _Nonnull))uploadProgre failure:(void (^)(NSError * _Nonnull error))failure {
    
    XSWeakSelf;
    
    
    
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
        
    /**
     *  可以接受的类型
     */
    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
    [manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Accept"];


    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript", nil];
    
    if(requestSerializerContentType){
        [manager.requestSerializer setValue:requestSerializerContentType forHTTPHeaderField:@"Content-Type"];
    }else{
        [manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
    }
//    [manager.requestSerializer setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
    /**
     *  请求超时的时间
     */
    manager.requestSerializer.timeoutInterval = 100;
    NSString *token = [[NSUserDefaults standardUserDefaults] valueForKey:@"token"];
    if (token) {
        [manager.requestSerializer setValue:token  forHTTPHeaderField:@"Authorization"];
//        NSLog(@"API_memberPlaceOrder--用户token==%@\n",token);
    }else{
        if([SSUserManager sharedUser].userModel.tempToken){
            token = [SSUserManager sharedUser].userModel.tempToken;
//            NSLog(@"API_memberPlaceOrder--访客token==%@\n",token);
            
            [manager.requestSerializer setValue:token  forHTTPHeaderField:@"Authorization"];
        }
        else{
            [manager.requestSerializer setValue:@"Basic Y2xpZW50LWFwOjFxYXp4c3cy"  forHTTPHeaderField:@"Authorization"];
        }
    }
    
    
    
//    NSString *finalURL = [API_BASEURL stringByAppendingString:url];
//    NSLog(@"请求的URL：%@",finalURL);
    
    NSString *TempFinalURL = [API_BASEURL stringByAppendingString:portStr];
    NSString *finalURL = [NSString stringWithFormat:@"%@%@",TempFinalURL,URLStr];
    NSLog(@"请求的URL：%@",finalURL);
    
    if(mimeTypeStr==nil||mimeTypeStr.length==0){
        mimeTypeStr = @"image/png";
    }
//    [manager POST:finalURL parameters:parameDict constructingBodyWithBlock:^(id<AFMultipartFormData>  _Nonnull formData) {
//
//        [formData appendPartWithFileData:fData name:@"upfile" fileName:fileNameStr mimeType:mimeTypeStr];
//        int a =  10;
//        } progress:^(NSProgress * _Nonnull uploadProgress) {
//            uploadProgre(uploadProgress);
//        } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
//            success(responseObject);
//        } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
//            failure(error);
//        }];
    [manager POST:finalURL parameters:parameDict headers:@{} constructingBodyWithBlock:^(id<AFMultipartFormData>  _Nonnull formData) {
        [formData appendPartWithFileData:fData name:(notNillStr(Field))?Field:@"upfile" fileName:fileNameStr mimeType:mimeTypeStr];
    } progress:^(NSProgress * _Nonnull uploadProgress) {
        uploadProgre(uploadProgress);
    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        
        success(responseObject);
        [weakSelf successHandling:responseObject requestUrl:finalURL];
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        failure(error);
    }];
}

#pragma mark  添加模板热度2
- (NSURLSessionDataTask *)POSTBodyAddTmpleteHotWithUrl:(NSString *)url withrequestSerializerContentType:(NSString *)requestSerializerContentType parameters:(id)parameters success:(void (^)(id _Nonnull responseObject))success failure:(void (^)(NSError * _Nonnull error))failure {
    
    XSWeakSelf;
    
    
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
        
    /**
     *  可以接受的类型
     */
    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
    [manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Accept"];


    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript", nil];
    
    if(requestSerializerContentType){
        [manager.requestSerializer setValue:requestSerializerContentType forHTTPHeaderField:@"Content-Type"];
    }else{
        [manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
    }
//    [manager.requestSerializer setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
    /**
     *  请求超时的时间
     */
    manager.requestSerializer.timeoutInterval = 100;
    NSString *token = [[NSUserDefaults standardUserDefaults] valueForKey:@"token"];
    if (token) {
        [manager.requestSerializer setValue:token  forHTTPHeaderField:@"Authorization"];
//        NSLog(@"API_memberPlaceOrder--用户token==%@\n",token);
    }else{
        if([SSUserManager sharedUser].userModel.tempToken){
            token = [SSUserManager sharedUser].userModel.tempToken;
//            NSLog(@"API_memberPlaceOrder--访客token==%@\n",token);
            
            [manager.requestSerializer setValue:token  forHTTPHeaderField:@"Authorization"];
        }
        else{
            [manager.requestSerializer setValue:@"Basic Y2xpZW50LWFwOjFxYXp4c3cy"  forHTTPHeaderField:@"Authorization"];
        }
    }
    NSString *jsonString2;
    NSMutableString *dataStr2 = [NSMutableString new];

    NSDictionary *parametersData2 = parameters;
    if(parametersData2.allKeys.count>0){
        for (int i = 0; i < parametersData2.count;  i ++) {
            NSString *key = parametersData2.allKeys[i];
            id value = parametersData2[key];
            [dataStr2 appendFormat:@"%@=%@&",key,value];
        }
        NSString *postStr = [dataStr2 substringWithRange:NSMakeRange(0, dataStr2.length - 1)];
        jsonString2 = postStr;//[postStr URLEncodedString];
    }else{
        jsonString2 =[NSString new];//[[NSString new] URLEncodedString];
    }

    NSString *finalURL = [API_BASEURL stringByAppendingString:url];
    finalURL = [NSString stringWithFormat:@"%@?%@",finalURL,jsonString2];
    NSLog(@"请求的URL：%@",finalURL);
    NSMutableURLRequest * request = [manager.requestSerializer requestWithMethod:@"POST" URLString:finalURL parameters:parameters error:nil];
    
    NSString *jsonString;
    if(requestSerializerContentType){
        [request setValue:requestSerializerContentType forHTTPHeaderField:@"Content-Type"];
        
        
        NSMutableString *dataStr = [NSMutableString new];
       
        NSDictionary *parametersData = parameters;
        if([parametersData isKindOfClass:[NSDictionary class]]){
//            if(parametersData.allKeys.count>0){
//                for (int i = 0; i < parametersData.count;  i ++) {
//                    NSString *key = parametersData.allKeys[i];
//                    id value = parametersData[key];
//                    [dataStr appendFormat:@"%@=%@&",key,value];
//                }
//                NSString *postStr = [dataStr substringWithRange:NSMakeRange(0, dataStr.length - 1)];
//                jsonString = postStr;
//            }else{
//                jsonString =[NSString new];
//            }
           jsonString = [NSString convertToJsonData:parametersData];
        }
        else{
            jsonString =[NSString new];
        }
        
    }else{
        [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
        
        NSData *jsonData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
        jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
        if(kStringIsEmpty(jsonString)){
            jsonString = [NSString new];
        }
    }
    

//    NSData *jsonData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
//    NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];

    NSData *bodyData = [jsonString dataUsingEncoding:NSUTF8StringEncoding];
    if(!bodyData){
        bodyData = [NSData new];
    }
    [request setHTTPBody:bodyData];
    
    NSURLSessionDataTask *task = [manager.session dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
        dispatch_async(dispatch_get_main_queue(), ^{
            if (error !=nil) {
                if (failure) {
                    failure(error);
                }
                
            }else{
                if (data) {
                    NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:nil];
                    [weakSelf successHandling:dict requestUrl:finalURL];
//                    NSLog(@"finalURL===%@\n请求响应：%@",finalURL,dict);
                    if (!dict) {
                        
#warning 暂时注释
#warning 暂时注释
#warning 暂时注释
#warning 暂时注释
//                        [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"token"];
//                        [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"cloudRootNodeID"];
//                        [[NSUserDefaults standardUserDefaults] synchronize];
//                        [[NSNotificationCenter defaultCenter] postNotificationName:@"authorLoginAccess" object:nil];

//                        [ZZMessageHud showMessage:@"登录失效，请重新登录" toView:[UIApplication sharedApplication].windows.firstObject];

                        NSDictionary *eroDict = @{@"code":@"401",@"msg":@"登录失效",@"data":@""};
                        if (success) {
                            success(eroDict);
                        }
                        return;
                    }
                    if (success) {
                        success(dict);
                    }
                    
                }
            }
        });
    }];
    [task resume];
    return task;
}


- (void )POSTBody2:(NSString *)url parameters:(id)parameters success:(void (^)(id _Nonnull))success failure:(void (^)(NSError * _Nonnull))failure {
    
    XSWeakSelf;
    
    
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
        
    /**
     *  可以接受的类型
     */
    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
    [manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Accept"];


    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript", nil];
    [manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
//    [manager.requestSerializer setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
    
    
    
    
    /**
     *  请求超时的时间
     */
    manager.requestSerializer.timeoutInterval = 100;
    NSString *token = [[NSUserDefaults standardUserDefaults] valueForKey:@"token"];
    if (token) {
        [manager.requestSerializer setValue:token  forHTTPHeaderField:@"Authorization"];
    }else{
        if([SSUserManager sharedUser].userModel.tempToken){
            token = [SSUserManager sharedUser].userModel.tempToken;
            NSLog(@"API_memberPlaceOrder--访客token==%@\n",token);
            
            [manager.requestSerializer setValue:token  forHTTPHeaderField:@"Authorization"];
        }else{
            
            [manager.requestSerializer setValue:@"Basic Y2xpZW50LWFwOjFxYXp4c3cy" forHTTPHeaderField:@"Authorization"];
        }
    }
    
    NSString *finalURL = [API_BASEURL stringByAppendingString:url];
    NSLog(@"请求的URL：%@",finalURL);
    
    
//    [manager POST:finalURL parameters:parameters progress:^(NSProgress * _Nonnull uploadProgress) {
//
//        } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
//            NSData *data = responseObject;
//            dispatch_async(dispatch_get_main_queue(), ^{
//                if (data) {
//                    NSDictionary *dict;// = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:nil];
//                    if([data isKindOfClass:[NSData class]]){
//                        dict = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:nil];
//                    }
////                    NSLog(@"finalURL===%@\n请求响应：%@",finalURL,dict);
//                    if (!dict) {
//
//#warning 暂时注释
//#warning 暂时注释
//#warning 暂时注释
//#warning 暂时注释
////                        [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"token"];
////                        [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"cloudRootNodeID"];
////                        [[NSUserDefaults standardUserDefaults] synchronize];
////                        [[NSNotificationCenter defaultCenter] postNotificationName:@"authorLoginAccess" object:nil];
//
////                        [ZZMessageHud showMessage:@"登录失效，请重新登录" toView:[UIApplication sharedApplication].windows.firstObject];
//
//                        NSDictionary *eroDict = @{@"code":@"401",@"msg":@"登录失效",@"data":@""};
//                        if (success) {
//                            success(eroDict);
//                        }
//                        return;
//                    }
//                    if (success) {
//                        success(dict);
//                    }
//
//                }
//            });
//        } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
//            if (error !=nil) {
//                if (failure) {
//                    failure(error);
//                }
//
//            }
//        }];
    
    
    
}



- (NSURLSessionDataTask *)GETUrlencoded:(NSString *)url withrequestSerializerContentType:(NSString *)requestSerializerContentType port:(NSString *)portStr parameters:(id)parameters success:(void (^)(id _Nonnull sucee))success failure:(void (^)(NSError * _Nonnull err))failure {
    
    XSWeakSelf;
    
    
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
        
    /**
     *  可以接受的类型
     */
    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
    [manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Accept"];


    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript", nil];
    
    if(requestSerializerContentType){
        [manager.requestSerializer setValue:requestSerializerContentType forHTTPHeaderField:@"Content-Type"];
    }else{
        [manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
    }
//    [manager.requestSerializer setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
    /**
     *  请求超时的时间
     */
    manager.requestSerializer.timeoutInterval = 100;
    NSString *token = [[NSUserDefaults standardUserDefaults] valueForKey:@"token"];
    if (token) {
        [manager.requestSerializer setValue:token  forHTTPHeaderField:@"Authorization"];
        NSLog(@"API_memberPlaceOrder--用户token==%@\n",token);
    }else{
        if([SSUserManager sharedUser].userModel.tempToken){
            token = [SSUserManager sharedUser].userModel.tempToken;
            NSLog(@"API_memberPlaceOrder--访客token==%@\n",token);
            
            [manager.requestSerializer setValue:token  forHTTPHeaderField:@"Authorization"];
        }
    }
    
    
    NSString *TempFinalURL = [API_BASEURL stringByAppendingString:portStr];
    NSString *finalURL = [NSString stringWithFormat:@"%@%@",TempFinalURL,url];
    NSLog(@"请求的URL：%@",finalURL);
    NSMutableURLRequest * request = [manager.requestSerializer requestWithMethod:@"GET" URLString:finalURL parameters:parameters error:nil];
    request.HTTPMethod = @"GET";
//    NSString *jsonString;
    if(requestSerializerContentType){
        [request setValue:requestSerializerContentType forHTTPHeaderField:@"Content-Type"];
        
        
//        NSMutableString *dataStr = [NSMutableString new];
//
//        NSDictionary *parametersData = parameters;
//        if(parametersData.allKeys.count>0){
//            for (int i = 0; i < parametersData.count;  i ++) {
//                NSString *key = parametersData.allKeys[i];
//                id value = parametersData[key];
//                [dataStr appendFormat:@"%@=%@&",key,value];
//            }
//            NSString *postStr = [dataStr substringWithRange:NSMakeRange(0, dataStr.length - 1)];
//            jsonString = postStr;
//        }else{
//            jsonString =[NSString new];
//        }
        
    }else{
        [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
        
//        NSData *jsonData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
//        jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
//        if(kStringIsEmpty(jsonString)){
//            jsonString = [NSString new];
//        }
    }
    

//    NSData *jsonData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
//    NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];

//    NSData *bodyData = [jsonString dataUsingEncoding:NSUTF8StringEncoding];
//    if(!bodyData){
//        bodyData = [NSData new];
//    }
//    [request setHTTPBody:bodyData];
    
    NSURLSessionDataTask *task = [manager.session dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
        dispatch_async(dispatch_get_main_queue(), ^{
            if (error !=nil) {
                if (failure) {
                    failure(error);
                }
                
            }else{
                if (data) {
                    NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:nil];
                    [weakSelf successHandling:dict requestUrl:finalURL];
//                    NSLog(@"finalURL===%@\n请求响应：%@",finalURL,dict);
                    if (!dict) {
                        
#warning 暂时注释
#warning 暂时注释
#warning 暂时注释
#warning 暂时注释
//                        [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"token"];
//                        [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"cloudRootNodeID"];
//                        [[NSUserDefaults standardUserDefaults] synchronize];
//                        [[NSNotificationCenter defaultCenter] postNotificationName:@"authorLoginAccess" object:nil];

//                        [ZZMessageHud showMessage:@"登录失效，请重新登录" toView:[UIApplication sharedApplication].windows.firstObject];

                        NSDictionary *eroDict = @{@"code":@"401",@"msg":@"登录失效",@"data":@""};
                        if (success) {
                            success(eroDict);
                        }
                        return;
                    }
                    if (success) {
                        success(dict);
                    }
                    
                }
            }
        });
    }];
    [task resume];
    return task;
}


- (NSURLSessionDataTask *)GET2:(NSString *)url withrequestSerializerContentType:(NSString *)requestSerializerContentType port:(NSString *)portStr parameters:(id)parameters success:(void (^)(id _Nonnull sucee))success failure:(void (^)(NSError * _Nonnull err))failure {
    
    XSWeakSelf;
    
    
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
        
    /**
     *  可以接受的类型
     */
    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
    [manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Accept"];


    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript", nil];
    
    if(requestSerializerContentType){
        [manager.requestSerializer setValue:requestSerializerContentType forHTTPHeaderField:@"Content-Type"];
    }else{
        [manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
    }
//    [manager.requestSerializer setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
    /**
     *  请求超时的时间
     */
    manager.requestSerializer.timeoutInterval = 100;
    NSString *token = [[NSUserDefaults standardUserDefaults] valueForKey:@"token"];
    if (token) {
        [manager.requestSerializer setValue:token  forHTTPHeaderField:@"Authorization"];
        NSLog(@"API_memberPlaceOrder--用户token==%@\n",token);
    }else{
        if([SSUserManager sharedUser].userModel.tempToken){
            token = [SSUserManager sharedUser].userModel.tempToken;
            NSLog(@"API_memberPlaceOrder--访客token==%@\n",token);
            
            [manager.requestSerializer setValue:token  forHTTPHeaderField:@"Authorization"];
        }
    }
    
    
    NSString *TempFinalURL = [API_BASEURL stringByAppendingString:portStr];
    NSString *finalURL = [NSString stringWithFormat:@"%@%@",TempFinalURL,url];
    NSLog(@"请求的URL：%@",finalURL);
    NSMutableURLRequest * request = [manager.requestSerializer requestWithMethod:@"GET" URLString:finalURL parameters:parameters error:nil];
    request.HTTPMethod = @"GET";
    NSString *jsonString;
    if(requestSerializerContentType){
        [request setValue:requestSerializerContentType forHTTPHeaderField:@"Content-Type"];
        
        
        NSMutableString *dataStr = [NSMutableString new];
       
        NSDictionary *parametersData = parameters;
        if(parametersData.allKeys.count>0){
            for (int i = 0; i < parametersData.count;  i ++) {
                NSString *key = parametersData.allKeys[i];
                id value = parametersData[key];
                [dataStr appendFormat:@"%@=%@&",key,value];
            }
            NSString *postStr = [dataStr substringWithRange:NSMakeRange(0, dataStr.length - 1)];
            jsonString = postStr;
        }else{
            jsonString =[NSString new];
        }
        
    }else{
        [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
        
        NSData *jsonData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
        jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
        if(kStringIsEmpty(jsonString)){
            jsonString = [NSString new];
        }
    }
    

//    NSData *jsonData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
//    NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];

//    NSData *bodyData = [jsonString dataUsingEncoding:NSUTF8StringEncoding];
//    if(!bodyData){
//        bodyData = [NSData new];
//    }
//    [request setHTTPBody:bodyData];
    
    NSURLSessionDataTask *task = [manager.session dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
        dispatch_async(dispatch_get_main_queue(), ^{
            if (error !=nil) {
                if (failure) {
                    failure(error);
                }
                
            }else{
                if (data) {
                    NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:nil];
                    [weakSelf successHandling:dict requestUrl:finalURL];
//                    NSLog(@"finalURL===%@\n请求响应：%@",finalURL,dict);
                    if (!dict) {
                        
#warning 暂时注释
#warning 暂时注释
#warning 暂时注释
#warning 暂时注释
//                        [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"token"];
//                        [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"cloudRootNodeID"];
//                        [[NSUserDefaults standardUserDefaults] synchronize];
//                        [[NSNotificationCenter defaultCenter] postNotificationName:@"authorLoginAccess" object:nil];

                        NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)response;
                        if(httpResponse.statusCode==200){
                            if (success) {
                                success(@{@"message":@"成功",@"data":@"null",@"code":@"200"});
                            }
                        }
                        else{
//                            [ZZMessageHud showMessage:@"登录失效，请重新登录" toView:[UIApplication sharedApplication].windows.firstObject];

                            NSDictionary *eroDict = @{@"code":@"401",@"msg":@"登录失效",@"data":@""};
                            if (success) {
                                success(eroDict);
                            }
                            return;
                        }
                       
                    }
                    if (success) {
                        success(dict);
                    }
                    
                }
            }
        });
    }];
    [task resume];
    return task;
}



- (NSURLSessionDataTask *)POSTBody:(NSString *)url timeout:(NSTimeInterval)tOut port:(NSString *)portStr parameters:(id)parameters success:(void (^)(id _Nonnull responseObject))success failure:(void (^)(NSError * _Nonnull error))failure {
    
    XSWeakSelf;
    
    
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
        
    /**
     *  可以接受的类型
     */
    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
    [manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Accept"];


    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript", nil];
    [manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
//    [manager.requestSerializer setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
    
    
    
    
    /**
     *  请求超时的时间
     */
    manager.requestSerializer.timeoutInterval = 100;
    if(tOut>0){
        manager.requestSerializer.timeoutInterval = tOut;
    }
    NSString *token = [[NSUserDefaults standardUserDefaults] valueForKey:@"token"];
    if (token) {
        [manager.requestSerializer setValue:token  forHTTPHeaderField:@"Authorization"];
    }else{
        if([SSUserManager sharedUser].userModel.tempToken){
            token = [SSUserManager sharedUser].userModel.tempToken;
            NSLog(@"API_memberPlaceOrder--访客token==%@\n",token);
            
            [manager.requestSerializer setValue:token  forHTTPHeaderField:@"Authorization"];
        }else{
            
            [manager.requestSerializer setValue:@"Basic Y2xpZW50LWFwOjFxYXp4c3cy" forHTTPHeaderField:@"Authorization"];
        }
    }
    
//    NSString *finalURL = [API_BASEURL stringByAppendingString:url];
//    NSLog(@"请求的URL：%@",finalURL);
    NSString *TempFinalURL = [API_BASEURL stringByAppendingString:portStr];
    NSString *finalURL = [NSString stringWithFormat:@"%@%@",TempFinalURL,url];
    NSLog(@"请求的URL：%@",finalURL);
    
    NSMutableURLRequest * request = [manager.requestSerializer requestWithMethod:@"POST" URLString:finalURL parameters:parameters error:nil];
    NSData *jsonData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
    NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
    NSLog(@"\n\njsonString==\n\n%@\n\n",jsonString);
    NSData *bodyData = [jsonString dataUsingEncoding:NSUTF8StringEncoding];
    [request setHTTPBody:bodyData];
    request.HTTPMethod = @"POST";
    NSURLSessionDataTask *task = [manager.session dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
        
        NSLog(@"request--URL：%@",finalURL);
        dispatch_async(dispatch_get_main_queue(), ^{
            if (error !=nil) {
                if (failure) {
                    failure(error);
                }
                
            }else{
                
//                NSDictionary *dict22 = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:nil];
                
                
//                if (data) {
//                    NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:nil];
////                    NSLog(@"finalURL===%@\n请求响应：%@",finalURL,dict);
//                    if (!dict) {
                NSDictionary *tempDictData;
                        if (data) {
                            NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:nil];
                            [weakSelf successHandling:dict requestUrl:finalURL];
        //                    NSLog(@"finalURL===%@\n请求响应：%@",finalURL,dict);
                            if (dict) {
                                tempDictData = dict;
                            }
                            
                        }
                        
                        NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)response;
                        if(httpResponse.statusCode==200){
                            if (success) {
                                
                                if(tempDictData){
                                    success(@{@"message":@"成功",@"data":tempDictData,@"code":@"200"});
                                }else{
                                    success(@{@"message":@"成功",@"data":@"null",@"code":@"200"});
                                }
                            }
                        }
                        else{
                            
    #warning 暂时注释
    #warning 暂时注释
    #warning 暂时注释
    #warning 暂时注释
    //                        [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"token"];
    //                        [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"cloudRootNodeID"];
    //                        [[NSUserDefaults standardUserDefaults] synchronize];
    //                        [[NSNotificationCenter defaultCenter] postNotificationName:@"authorLoginAccess" object:nil];

//                            [ZZMessageHud showMessage:@"登录失效，请重新登录" toView:[UIApplication sharedApplication].windows.firstObject];
                            
                            NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)response;
                            if(httpResponse.statusCode==500){
                                NSDictionary *eroDict = @{@"code":@"500",@"msg":@"系统繁忙",@"data":@""};
                                if (success) {
                                    success(eroDict);
                                }
                                return;
                            }
                            else{
                                NSDictionary *eroDict = @{@"code":@"401",@"msg":@"登录失效",@"data":@""};
                                if (success) {
                                    success(eroDict);
                                }
                                return;
                            }

                            
                        }
//                    }
//                    if (success) {
//                        success(dict);
//                    }
//
//                }
            }
        });
    }];
    [task resume];
    return task;
}

//MimeTyp
//超文本标记语言文本.html text/html
//
//xml文档.xml text/xml
//
//XHTML文档.xhtml application/xhtml+xml
//
//普通文本.txt text/plain
//
//RTF文本.rtf application/rtf
//
//PDF文档.pdf application/pdf
//
//Microsoft Word文件.word application/msword
//
//PNG图像.png image/png
//
//GIF图形.gif image/gif
//
//JPEG图形.jpeg,.jpg image/jpeg
//
//au声音文件.au audio/basic
//
//MIDI音乐文件mid,.midi audio/midi,audio/x-midi
//
//RealAudio音乐文件.ra, .ram audio/x-pn-realaudio
//
//MPEG文件.mpg,.mpeg video/mpeg
//
//AVI文件.avi video/x-msvideo
//
//GZIP文件.gz application/x-gzip
//
//TAR文件.tar application/x-tar
//
//任意的二进制数据application/octet-stream
// 上传电子数据指纹数据 文件
- (void)uploadElectroniDataFingerprintFileWithUrl:(NSString *)URLStr Port:(NSString *)portStr serverFileName:(NSString *)serverFileNameStr withrequestSerializerContentType:(NSString *)requestSerializerContentType  withFileData:(NSData *)fData withFileName:(NSString *)fileNameStr withMimeType:(NSString *)mimeTypeStr withParame:(NSDictionary *)parameDict success:(void (^)(id _Nonnull responseObject))success progress:(nullable void (^)(NSProgress * _Nonnull))uploadProgre failure:(void (^)(NSError * _Nonnull error))failure {
    
    XSWeakSelf;
    
    
    
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
        
    /**
     *  可以接受的类型
     */
    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
    [manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Accept"];


    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript", nil];
    
    if(requestSerializerContentType){
        [manager.requestSerializer setValue:requestSerializerContentType forHTTPHeaderField:@"Content-Type"];
    }else{
        [manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
    }
//    [manager.requestSerializer setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
    /**
     *  请求超时的时间
     */
    manager.requestSerializer.timeoutInterval = 100;
    NSString *token = [[NSUserDefaults standardUserDefaults] valueForKey:@"token"];
    if (token) {
        [manager.requestSerializer setValue:token  forHTTPHeaderField:@"Authorization"];
//        NSLog(@"API_memberPlaceOrder--用户token==%@\n",token);
    }else{
        if([SSUserManager sharedUser].userModel.tempToken){
            token = [SSUserManager sharedUser].userModel.tempToken;
//            NSLog(@"API_memberPlaceOrder--访客token==%@\n",token);
            
            [manager.requestSerializer setValue:token  forHTTPHeaderField:@"Authorization"];
        }
        else{
            [manager.requestSerializer setValue:@"Basic Y2xpZW50LWFwOjFxYXp4c3cy"  forHTTPHeaderField:@"Authorization"];
        }
    }
    
    
    
//    NSString *finalURL = [API_BASEURL stringByAppendingString:url];
//    NSLog(@"请求的URL：%@",finalURL);
    
    NSString *TempFinalURL = [API_BASEURL stringByAppendingString:portStr];
    NSString *finalURL = [NSString stringWithFormat:@"%@%@",TempFinalURL,URLStr];
    NSLog(@"请求的URL：%@",finalURL);
    
    if(mimeTypeStr==nil||mimeTypeStr.length==0){
        mimeTypeStr = @"image/png";
    }
//    [manager POST:finalURL parameters:parameDict constructingBodyWithBlock:^(id<AFMultipartFormData>  _Nonnull formData) {
//
//
//        if(notNillStr(serverFileNameStr)){
//            [formData appendPartWithFileData:fData name:serverFileNameStr fileName:fileNameStr mimeType:mimeTypeStr];
//        }
//        else{
//            [formData appendPartWithFileData:fData name:@"upfile" fileName:fileNameStr mimeType:mimeTypeStr];
//        }
////        int a =  10;
//        } progress:^(NSProgress * _Nonnull uploadProgress) {
//            uploadProgre(uploadProgress);
//        } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
//            success(responseObject);
//        } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
//            failure(error);
//        }];
}

- (void)uploadFileWithUrl3:(NSString *)URLStr Port:(NSString *)portStr withrequestSerializerContentType:(NSString *)requestSerializerContentType  withFileData:(NSData *)fData withFileName:(NSString *)fileNameStr withMimeType:(NSString *)mimeTypeStr withParame:(NSDictionary *)parameDict success:(void (^)(id _Nonnull responseObject))success progress:(nullable void (^)(NSProgress * _Nonnull))uploadProgre failure:(void (^)(NSError * _Nonnull error))failure {
    
    XSWeakSelf;
    
    
    
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
        
    /**
     *  可以接受的类型
     */
    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
    [manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Accept"];


    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript", nil];
    
    if(requestSerializerContentType){
        [manager.requestSerializer setValue:requestSerializerContentType forHTTPHeaderField:@"Content-Type"];
    }else{
        [manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
    }
//    [manager.requestSerializer setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
    /**
     *  请求超时的时间
     */
    manager.requestSerializer.timeoutInterval = 100;
    NSString *token = [[NSUserDefaults standardUserDefaults] valueForKey:@"token"];
    if (token) {
        [manager.requestSerializer setValue:token  forHTTPHeaderField:@"Authorization"];
//        NSLog(@"API_memberPlaceOrder--用户token==%@\n",token);
    }else{
        if([SSUserManager sharedUser].userModel.tempToken){
            token = [SSUserManager sharedUser].userModel.tempToken;
//            NSLog(@"API_memberPlaceOrder--访客token==%@\n",token);
            
            [manager.requestSerializer setValue:token  forHTTPHeaderField:@"Authorization"];
        }
        else{
            [manager.requestSerializer setValue:@"Basic Y2xpZW50LWFwOjFxYXp4c3cy"  forHTTPHeaderField:@"Authorization"];
        }
    }
    
    
    
//    NSString *finalURL = [API_BASEURL stringByAppendingString:url];
//    NSLog(@"请求的URL：%@",finalURL);
    
    NSString *TempFinalURL = [API_BASEURL stringByAppendingString:portStr];
    NSString *finalURL = [NSString stringWithFormat:@"%@%@",TempFinalURL,URLStr];
    NSLog(@"请求的URL：%@",finalURL);
    
    if(mimeTypeStr==nil||mimeTypeStr.length==0){
        mimeTypeStr = @"image/png";
    }
    
    [manager POST:finalURL parameters:parameDict headers:@{} constructingBodyWithBlock:^(id<AFMultipartFormData>  _Nonnull formData) {
        [formData appendPartWithFileData:fData name:@"file" fileName:fileNameStr mimeType:mimeTypeStr];
    } progress:^(NSProgress * _Nonnull uploadProgress) {
        uploadProgre(uploadProgress);
    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        success(responseObject);
        [weakSelf successHandling:responseObject requestUrl:finalURL];
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        failure(error);
    }];
}



- (NSURLSessionDataTask *)POSTBodyTouristsRegister:(NSString *)url withrequestSerializerContentType:(NSString *)requestSerializerContentType parameters:(id)parameters success:(void (^)(id _Nonnull responseObject))success failure:(void (^)(NSError * _Nonnull error))failure {
    
    XSWeakSelf;
    
    
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
        
    /**
     *  可以接受的类型
     */
    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
    [manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Accept"];


    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript", nil];
    
    if(requestSerializerContentType){
        [manager.requestSerializer setValue:requestSerializerContentType forHTTPHeaderField:@"Content-Type"];
    }else{
        [manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
    }
//    [manager.requestSerializer setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
    /**
     *  请求超时的时间
     */
    manager.requestSerializer.timeoutInterval = 100;
//    NSString *token = [[NSUserDefaults standardUserDefaults] valueForKey:@"token"];
//    if (token) {
//        [manager.requestSerializer setValue:token  forHTTPHeaderField:@"Authorization"];
////        NSLog(@"API_memberPlaceOrder--用户token==%@\n",token);
//    }else{
//        if([SSUserManager sharedUser].userModel.tempToken){
//            token = [SSUserManager sharedUser].userModel.tempToken;
////            NSLog(@"API_memberPlaceOrder--访客token==%@\n",token);
//
//            [manager.requestSerializer setValue:token  forHTTPHeaderField:@"Authorization"];
//        }
//        else{
            [manager.requestSerializer setValue:@"Basic Y2xpZW50LWFwOjFxYXp4c3cy"  forHTTPHeaderField:@"Authorization"];
//        }
//    }
    
    
    NSString *finalURL = [touristsRegister_BASEURL stringByAppendingString:url];
    NSLog(@"请求的URL：%@",finalURL);
    NSMutableURLRequest * request = [manager.requestSerializer requestWithMethod:@"POST" URLString:finalURL parameters:parameters error:nil];
    
    NSString *jsonString;
    if(requestSerializerContentType){
        [request setValue:requestSerializerContentType forHTTPHeaderField:@"Content-Type"];
        
        
        NSMutableString *dataStr = [NSMutableString new];
       
        NSDictionary *parametersData = parameters;
        if(parametersData.allKeys.count>0){
            for (int i = 0; i < parametersData.count;  i ++) {
                NSString *key = parametersData.allKeys[i];
                id value = parametersData[key];
                [dataStr appendFormat:@"%@=%@&",key,value];
            }
            NSString *postStr = [dataStr substringWithRange:NSMakeRange(0, dataStr.length - 1)];
            jsonString = postStr;
        }else{
            jsonString =[NSString new];
        }
        
    }else{
        [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
        
        NSData *jsonData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
        jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
        if(kStringIsEmpty(jsonString)){
            jsonString = [NSString new];
        }
    }
    

//    NSData *jsonData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
//    NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];

    NSData *bodyData = [jsonString dataUsingEncoding:NSUTF8StringEncoding];
    if(!bodyData){
        bodyData = [NSData new];
    }
    [request setHTTPBody:bodyData];
    
    NSURLSessionDataTask *task = [manager.session dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
        dispatch_async(dispatch_get_main_queue(), ^{
            if (error !=nil) {
                if (failure) {
                    failure(error);
                }
                
            }else{
                if (data) {
                    NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:nil];
                    [weakSelf successHandling:dict requestUrl:finalURL];
//                    NSLog(@"finalURL===%@\n请求响应：%@",finalURL,dict);
                    if (!dict) {
                        
#warning 暂时注释
#warning 暂时注释
#warning 暂时注释
#warning 暂时注释
//                        [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"token"];
//                        [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"cloudRootNodeID"];
//                        [[NSUserDefaults standardUserDefaults] synchronize];
//                        [[NSNotificationCenter defaultCenter] postNotificationName:@"authorLoginAccess" object:nil];

//                        [ZZMessageHud showMessage:@"登录失效，请重新登录" toView:[UIApplication sharedApplication].windows.firstObject];

                        NSDictionary *eroDict = @{@"code":@"401",@"msg":@"登录失效",@"data":@""};
                        if (success) {
                            success(eroDict);
                        }
                        return;
                    }
                    if (success) {
                        success(dict);
                    }
                    
                }
            }
        });
    }];
    [task resume];
    return task;
}


#pragma mark 语境库设置选中
- (NSURLSessionDataTask *)GETBodySetSelect:(NSString *)url withrequestSerializerContentType:(NSString *)requestSerializerContentType parameters:(id)parameters success:(void (^)(id _Nonnull sucee))success failure:(void (^)(NSError * _Nonnull err))failure {
    
    XSWeakSelf;
    
    
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
        
    /**
     *  可以接受的类型
     */
    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
    [manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Accept"];


    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript", nil];
    
    if(requestSerializerContentType){
        [manager.requestSerializer setValue:requestSerializerContentType forHTTPHeaderField:@"Content-Type"];
    }else{
        [manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
    }
//    [manager.requestSerializer setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
    /**
     *  请求超时的时间
     */
    manager.requestSerializer.timeoutInterval = 100;
    NSString *token = [[NSUserDefaults standardUserDefaults] valueForKey:@"token"];
    if (token) {
        [manager.requestSerializer setValue:token  forHTTPHeaderField:@"Authorization"];
        NSLog(@"API_memberPlaceOrder--用户token==%@\n",token);
    }else{
        if([SSUserManager sharedUser].userModel.tempToken){
            token = [SSUserManager sharedUser].userModel.tempToken;
            NSLog(@"API_memberPlaceOrder--访客token==%@\n",token);
            
            [manager.requestSerializer setValue:token  forHTTPHeaderField:@"Authorization"];
        }
    }
    
    
    
    NSString *finalURL = [API_BASEURL stringByAppendingString:url];
    
            NSMutableString *dataStr = [NSMutableString new];
    NSString *jsonString;
            NSDictionary *parametersData = parameters;
            if(parametersData.allKeys.count>0){
                for (int i = 0; i < parametersData.count;  i ++) {
                    NSString *key = parametersData.allKeys[i];
                    id value = parametersData[key];
                    [dataStr appendFormat:@"%@=%@&",key,value];
                }
                NSString *postStr = [dataStr substringWithRange:NSMakeRange(0, dataStr.length - 1)];
                jsonString = postStr;
            }else{
                jsonString =[NSString new];
            }
    finalURL = [NSString stringWithFormat:@"%@?%@",finalURL,jsonString];
    
    NSLog(@"请求的URL：%@",finalURL);
    NSMutableURLRequest * request = [manager.requestSerializer requestWithMethod:@"GET" URLString:finalURL parameters:parameters error:nil];
    request.HTTPMethod = @"GET";
//    NSString *jsonString;
    if(requestSerializerContentType){
        [request setValue:requestSerializerContentType forHTTPHeaderField:@"Content-Type"];
        
        
//        NSMutableString *dataStr = [NSMutableString new];
//
//        NSDictionary *parametersData = parameters;
//        if(parametersData.allKeys.count>0){
//            for (int i = 0; i < parametersData.count;  i ++) {
//                NSString *key = parametersData.allKeys[i];
//                id value = parametersData[key];
//                [dataStr appendFormat:@"%@=%@&",key,value];
//            }
//            NSString *postStr = [dataStr substringWithRange:NSMakeRange(0, dataStr.length - 1)];
//            jsonString = postStr;
//        }else{
//            jsonString =[NSString new];
//        }
        
    }else{
        [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
        
//        NSData *jsonData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
//        jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
//        if(kStringIsEmpty(jsonString)){
//            jsonString = [NSString new];
//        }
    }
    

//    NSData *jsonData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
//    NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];

//    NSData *bodyData = [jsonString dataUsingEncoding:NSUTF8StringEncoding];
//    if(!bodyData){
//        bodyData = [NSData new];
//    }
//    [request setHTTPBody:bodyData];
    
    NSURLSessionDataTask *task = [manager.session dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
        dispatch_async(dispatch_get_main_queue(), ^{
            if (error !=nil) {
                if (failure) {
                    failure(error);
                }
                
            }else{
                if (data) {
                    NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:nil];
                    [weakSelf successHandling:dict requestUrl:finalURL];
//                    NSLog(@"finalURL===%@\n请求响应：%@",finalURL,dict);
                    if (!dict) {
                        
#warning 暂时注释
#warning 暂时注释
#warning 暂时注释
#warning 暂时注释
//                        [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"token"];
//                        [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"cloudRootNodeID"];
//                        [[NSUserDefaults standardUserDefaults] synchronize];
//                        [[NSNotificationCenter defaultCenter] postNotificationName:@"authorLoginAccess" object:nil];

//                        [ZZMessageHud showMessage:@"登录失效，请重新登录" toView:[UIApplication sharedApplication].windows.firstObject];

                        NSDictionary *eroDict = @{@"code":@"401",@"msg":@"登录失效",@"data":@""};
                        if (success) {
                            success(eroDict);
                        }
                        return;
                    }
                    if (success) {
                        success(dict);
                    }
                    
                }
            }
        });
    }];
    [task resume];
    return task;
}

#pragma mark 添加汇编
- (NSURLSessionDataTask *)POSTBodyAddHuiBian:(NSString *)url withrequestSerializerContentType:(NSString *)requestSerializerContentType parameters:(id)parameters success:(void (^)(id _Nonnull responseObject))success failure:(void (^)(NSError * _Nonnull error))failure {
    
    XSWeakSelf;
    
    
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
        
    /**
     *  可以接受的类型
     */
    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
    [manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Accept"];


    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript", nil];
    
    if(requestSerializerContentType){
        [manager.requestSerializer setValue:requestSerializerContentType forHTTPHeaderField:@"Content-Type"];
    }else{
        [manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
    }
//    [manager.requestSerializer setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
    /**
     *  请求超时的时间
     */
    manager.requestSerializer.timeoutInterval = 100;
    NSString *token = [[NSUserDefaults standardUserDefaults] valueForKey:@"token"];
    if (token) {
        [manager.requestSerializer setValue:token  forHTTPHeaderField:@"Authorization"];
//        NSLog(@"API_memberPlaceOrder--用户token==%@\n",token);
    }else{
        if([SSUserManager sharedUser].userModel.tempToken){
            token = [SSUserManager sharedUser].userModel.tempToken;
//            NSLog(@"API_memberPlaceOrder--访客token==%@\n",token);
            
            [manager.requestSerializer setValue:token  forHTTPHeaderField:@"Authorization"];
        }
        else{
            [manager.requestSerializer setValue:@"Basic Y2xpZW50LWFwOjFxYXp4c3cy"  forHTTPHeaderField:@"Authorization"];
        }
    }
//    NSString *jsonString2;
//    NSMutableString *dataStr2 = [NSMutableString new];
//
//    NSDictionary *parametersData2 = parameters;
//    if(parametersData2.allKeys.count>0){
//        for (int i = 0; i < parametersData2.count;  i ++) {
//            NSString *key = parametersData2.allKeys[i];
//            id value = parametersData2[key];
//            [dataStr2 appendFormat:@"%@=%@&",key,value];
//        }
//        NSString *postStr = [dataStr2 substringWithRange:NSMakeRange(0, dataStr2.length - 1)];
//        jsonString2 = [postStr URLEncodedString];
//    }else{
//        jsonString2 =[[NSString new] URLEncodedString];
//    }
//
    NSString *finalURL = [API_BASEURL stringByAppendingString:url];
//    finalURL = [NSString stringWithFormat:@"%@?%@",finalURL,jsonString2];
    NSLog(@"请求的URL：%@",finalURL);
    NSMutableURLRequest * request = [manager.requestSerializer requestWithMethod:@"POST" URLString:finalURL parameters:parameters error:nil];
    
    NSString *jsonString;
    if(requestSerializerContentType){
        [request setValue:requestSerializerContentType forHTTPHeaderField:@"Content-Type"];
        
        
        NSMutableString *dataStr = [NSMutableString new];
       
        NSDictionary *parametersData = parameters;
        if([parametersData isKindOfClass:[NSDictionary class]]){
//            if(parametersData.allKeys.count>0){
//
//                for (int i = 0; i < parametersData.count;  i ++) {
//                    NSString *key = parametersData.allKeys[i];
//                    id value = parametersData[key];
//                    [dataStr appendFormat:@"%@:%@&",key,value];
//                }
//
//                NSString *postStr = [dataStr substringWithRange:NSMakeRange(0, dataStr.length - 1)];
////                [dataStr appendFormat:@"%@",@"{"];
////                [dataStr appendFormat:@"%@",@"}"];
//                jsonString = [NSString stringWithFormat:@"%@%@%@",@"{",postStr,@"}"];
//            }else{
//                jsonString =[NSString new];
//            }
            jsonString = [NSString convertToJsonData:parameters];
        }
        else{
            jsonString =[NSString new];
        }
        
    }else{
        [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
        
        NSData *jsonData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
        jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
        if(kStringIsEmpty(jsonString)){
            jsonString = [NSString new];
        }
    }
    

//    NSData *jsonData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
//    NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
    
    NSData *bodyData = [jsonString dataUsingEncoding:NSUTF8StringEncoding];

    if(!bodyData){
        bodyData = [NSData new];
    }
    [request setHTTPBody:bodyData];
    
    NSURLSessionDataTask *task = [manager.session dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
        dispatch_async(dispatch_get_main_queue(), ^{
            if (error !=nil) {
                if (failure) {
                    failure(error);
                }
                
            }else{
                if (data) {
                    NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:nil];
                    [weakSelf successHandling:dict requestUrl:finalURL];
//                    NSLog(@"finalURL===%@\n请求响应：%@",finalURL,dict);
                    if (!dict) {
                        
#warning 暂时注释
#warning 暂时注释
#warning 暂时注释
#warning 暂时注释
//                        [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"token"];
//                        [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"cloudRootNodeID"];
//                        [[NSUserDefaults standardUserDefaults] synchronize];
//                        [[NSNotificationCenter defaultCenter] postNotificationName:@"authorLoginAccess" object:nil];

//                        [ZZMessageHud showMessage:@"登录失效，请重新登录" toView:[UIApplication sharedApplication].windows.firstObject];

                        NSDictionary *eroDict = @{@"code":@"401",@"msg":@"登录失效",@"data":@""};
                        if (success) {
                            success(eroDict);
                        }
                        return;
                    }
                    if (success) {
                        success(dict);
                    }
                    
                }
            }
        });
    }];
    [task resume];
    return task;
}

#pragma mark CommonQuery
- (void)postCommonQueryWithFullUrl:(NSString *)finalURL withrequestSerializerContentType:(NSString *)requestSerializerContentType  withImagesArray:(NSArray *)images withParame:(NSDictionary *)parameDict success:(void (^)(id _Nonnull responseObject))success progress:(nullable void (^)(NSProgress * _Nonnull))uploadProgre failure:(void (^)(NSError * _Nonnull error))failure {
    
    XSWeakSelf;
    
    
    
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
        
    /**
     *  可以接受的类型
     */
    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
    [manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Accept"];


    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript", nil];
    
    if(requestSerializerContentType){
        [manager.requestSerializer setValue:requestSerializerContentType forHTTPHeaderField:@"Content-Type"];
    }else{
        [manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
    }
//    [manager.requestSerializer setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
    /**
     *  请求超时的时间
     */
    manager.requestSerializer.timeoutInterval = 100;
    NSString *token = [[NSUserDefaults standardUserDefaults] valueForKey:@"token"];
    if (token) {
        [manager.requestSerializer setValue:token  forHTTPHeaderField:@"Authorization"];
//        NSLog(@"API_memberPlaceOrder--用户token==%@\n",token);
    }else{
        if([SSUserManager sharedUser].userModel.tempToken){
            token = [SSUserManager sharedUser].userModel.tempToken;
//            NSLog(@"API_memberPlaceOrder--访客token==%@\n",token);
            
            [manager.requestSerializer setValue:token  forHTTPHeaderField:@"Authorization"];
        }
        else{
            [manager.requestSerializer setValue:@"Basic Y2xpZW50LWFwOjFxYXp4c3cy"  forHTTPHeaderField:@"Authorization"];
        }
    }
    
    
    
//    NSString *finalURL = [API_BASEURL stringByAppendingString:url];
//    NSLog(@"请求的URL：%@",finalURL);
    
//    NSString *TempFinalURL = [@"http://creword.com/crewordapi/" stringByAppendingString:portStr];
//    NSString *finalURL = [NSString stringWithFormat:@"%@%@",TempFinalURL,URLStr];
    NSLog(@"请求的URL：%@",finalURL);
    
    
    [manager POST:finalURL parameters:parameDict headers:@{@"Authorization":token} constructingBodyWithBlock:^(id<AFMultipartFormData>  _Nonnull formData) {
        for (int i=0; i<images.count; i++) {
//            UIImage *tpImg = images[i];
            NSData *imgData = [@"tempStr" dataUsingEncoding:NSUTF8StringEncoding];//[NSData alloc];//UIImagePNGRepresentation(tpImg);
            NSDateFormatter *formatter =[[NSDateFormatter alloc] init];
            [formatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
            NSString *dString = [formatter stringFromDate:[NSDate date]];

            NSString *fileNameStr = [NSString stringWithFormat:@"file%d%@",i,dString];
            [formData appendPartWithFileData:imgData name:@"name" fileName:fileNameStr mimeType:@"image/png"];
        }

    } progress:^(NSProgress * _Nonnull uploadProgress) {
        
    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        success(responseObject);
        [weakSelf successHandling:responseObject requestUrl:finalURL];
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        failure(error);
    }];
    
}





//- (NSURLSessionDataTask *)GETBodyFullUrl:(NSString *)finalURL withrequestSerializerContentType:(NSString *)requestSerializerContentType parameters:(id)parameters success:(void (^)(id _Nonnull sucee))success failure:(void (^)(NSError * _Nonnull err))failure {
    

    
//    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
//
//    /**
//     *  可以接受的类型
//     */
//    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
//    [manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Accept"];
//
//
//    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript", nil];
//
//    if(requestSerializerContentType){
//        [manager.requestSerializer setValue:requestSerializerContentType forHTTPHeaderField:@"Content-Type"];
//    }else{
//        [manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
//    }
////    [manager.requestSerializer setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
//    /**
//     *  请求超时的时间
//     */
//    manager.requestSerializer.timeoutInterval = 100;
//    NSString *token = [[NSUserDefaults standardUserDefaults] valueForKey:@"token"];
//    if (token) {
//        [manager.requestSerializer setValue:token  forHTTPHeaderField:@"Authorization"];
//        NSLog(@"API_memberPlaceOrder--用户token==%@\n",token);
//    }else{
//        if([SSUserManager sharedUser].userModel.tempToken){
//            token = [SSUserManager sharedUser].userModel.tempToken;
//            NSLog(@"API_memberPlaceOrder--访客token==%@\n",token);
//
//            [manager.requestSerializer setValue:token  forHTTPHeaderField:@"Authorization"];
//        }
//    }
//
//
//
////    NSString *finalURL = [API_BASEURL stringByAppendingString:url];
//
//            NSMutableString *dataStr = [NSMutableString new];
//    NSString *jsonString;
//            NSDictionary *parametersData = parameters;
//            if(parametersData.allKeys.count>0){
//                for (int i = 0; i < parametersData.count;  i ++) {
//                    NSString *key = parametersData.allKeys[i];
//                    id value = parametersData[key];
//                    [dataStr appendFormat:@"%@=%@&",key,value];
//                }
//                NSString *postStr = [dataStr substringWithRange:NSMakeRange(0, dataStr.length - 1)];
//                jsonString = postStr;
//            }else{
//                jsonString =[NSString new];
//            }
//    if(jsonString.length>0){
//        finalURL = [NSString stringWithFormat:@"%@?%@",finalURL,jsonString];
//    }
//
//    NSLog(@"请求的jsonString==%@",jsonString);
//    NSLog(@"请求的UR==%@",finalURL);
//    NSMutableURLRequest * request = [manager.requestSerializer requestWithMethod:@"GET" URLString:finalURL parameters:parameters error:nil];
//    request.HTTPMethod = @"GET";
////    NSString *jsonString;
//    if(requestSerializerContentType){
//        [request setValue:requestSerializerContentType forHTTPHeaderField:@"Content-Type"];
//
//
////        NSMutableString *dataStr = [NSMutableString new];
////
////        NSDictionary *parametersData = parameters;
////        if(parametersData.allKeys.count>0){
////            for (int i = 0; i < parametersData.count;  i ++) {
////                NSString *key = parametersData.allKeys[i];
////                id value = parametersData[key];
////                [dataStr appendFormat:@"%@=%@&",key,value];
////            }
////            NSString *postStr = [dataStr substringWithRange:NSMakeRange(0, dataStr.length - 1)];
////            jsonString = postStr;
////        }else{
////            jsonString =[NSString new];
////        }
//
//    }else{
//        [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
//
////        NSData *jsonData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
////        jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
////        if(kStringIsEmpty(jsonString)){
////            jsonString = [NSString new];
////        }
//    }
//
//
////    NSData *jsonData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
////    NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
//
////    NSData *bodyData = [jsonString dataUsingEncoding:NSUTF8StringEncoding];
////    if(!bodyData){
////        bodyData = [NSData new];
////    }
////    [request setHTTPBody:bodyData];
//
//    NSURLSessionDataTask *task = [manager.session dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
//        if (error !=nil) {
//            if (failure) {
//                failure(error);
//            }
//
//        }else{
//            if (data) {
//                NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:nil];
////                    NSLog(@"finalURL===%@\n请求响应：%@",finalURL,dict);
//                if (!dict) {
//
//#warning 暂时注释
//#warning 暂时注释
//#warning 暂时注释
//#warning 暂时注释
////                        [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"token"];
////                        [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"cloudRootNodeID"];
////                        [[NSUserDefaults standardUserDefaults] synchronize];
////                        [[NSNotificationCenter defaultCenter] postNotificationName:@"authorLoginAccess" object:nil];
//
////                        [ZZMessageHud showMessage:@"登录失效，请重新登录" toView:[UIApplication sharedApplication].windows.firstObject];
//
////                        NSDictionary *eroDict = @{@"code":@"401",@"msg":@"登录失效",@"data":@""};
////                        if (success) {
////                            success(eroDict);
////                        }
////                        return;
//                    NSDictionary *tempDictData = [NSDictionary new];
////                                if (data) {
////                                    NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:nil];
////                //                    NSLog(@"finalURL===%@\n请求响应：%@",finalURL,dict);
////                                    if (dict) {
////                                        tempDictData = dict;
////                                    }
////
////                                }
//
//                            NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)response;
//                            if(httpResponse.statusCode==200){
//                                if (success) {
//
//                                    if(tempDictData){
//                                        success(@{@"message":@"成功",@"data":tempDictData,@"code":@"200"});
//                                        return;
//                                    }else{
//                                        success(@{@"message":@"成功",@"data":@"null",@"code":@"200"});
//                                        return;
//                                    }
//                                }
//                            }
//                            else{
//
//        #warning 暂时注释
//        #warning 暂时注释
//        #warning 暂时注释
//        #warning 暂时注释
//        //                        [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"token"];
//        //                        [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"cloudRootNodeID"];
//        //                        [[NSUserDefaults standardUserDefaults] synchronize];
//        //                        [[NSNotificationCenter defaultCenter] postNotificationName:@"authorLoginAccess" object:nil];
//
//    //                            [ZZMessageHud showMessage:@"登录失效，请重新登录" toView:[UIApplication sharedApplication].windows.firstObject];
//
//                                NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)response;
//                                if(httpResponse.statusCode==500){
//                                    NSDictionary *eroDict = @{@"code":@"500",@"msg":@"系统繁忙",@"data":@""};
//                                    if (success) {
//                                        success(eroDict);
//                                    }
//                                    return;
//                                }
//                                else{
//                                    NSDictionary *eroDict = @{@"code":@"401",@"msg":@"登录失效",@"data":@""};
//                                    if (success) {
//                                        success(eroDict);
//                                    }
//                                    return;
//                                }
//                    }
//                }
//                if (success) {
//                    success(dict);
//                }
//
//            }
//        }
//    }];
//    [task resume];
//    return task;
//}




#pragma mark - 订单zhif成功回调
- (NSURLSessionDataTask *)POSTBodyFullUrlOrder:(NSString *)finalURL withrequestSerializerContentType:(NSString *)requestSerializerContentType parameters:(id)parameters success:(void (^)(id _Nonnull responseObject))success failure:(void (^)(NSError * _Nonnull error))failure {
    
    XSWeakSelf;
    
    
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
        
    /**
     *  可以接受的类型
     */
    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
    [manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Accept"];


    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript", nil];
    
    if(requestSerializerContentType){
        [manager.requestSerializer setValue:requestSerializerContentType forHTTPHeaderField:@"Content-Type"];
    }else{
        [manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
    }
//    [manager.requestSerializer setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
    /**
     *  请求超时的时间
     */
    manager.requestSerializer.timeoutInterval = 100;
    NSString *token = [[NSUserDefaults standardUserDefaults] valueForKey:@"token"];
    if (token) {
        [manager.requestSerializer setValue:token  forHTTPHeaderField:@"Authorization"];
//        NSLog(@"API_memberPlaceOrder--用户token==%@\n",token);
    }else{
        if([SSUserManager sharedUser].userModel.tempToken){
            token = [SSUserManager sharedUser].userModel.tempToken;
//            NSLog(@"API_memberPlaceOrder--访客token==%@\n",token);
            
            [manager.requestSerializer setValue:token  forHTTPHeaderField:@"Authorization"];
        }
        else{
            [manager.requestSerializer setValue:@"Basic Y2xpZW50LWFwOjFxYXp4c3cy"  forHTTPHeaderField:@"Authorization"];
        }
    }
    
//    NSString *finalURL = [API_BASEURL stringByAppendingString:url];
    
    
    NSString *jsonString2;
    NSMutableString *dataStr2 = [NSMutableString new];

    NSDictionary *parametersData2 = parameters;
    if(parametersData2.allKeys.count>0){
        for (int i = 0; i < parametersData2.count;  i ++) {
            NSString *key = parametersData2.allKeys[i];
            id value = parametersData2[key];
            [dataStr2 appendFormat:@"%@=%@&",key,value];
        }
        NSString *postStr = [dataStr2 substringWithRange:NSMakeRange(0, dataStr2.length - 1)];
    }else{
        jsonString2 =[NSString new];
    }
    NSData *data2 = [jsonString2 dataUsingEncoding:NSUTF8StringEncoding];
    
    NSLog(@"请求的URL：%@",finalURL);
    NSMutableURLRequest * request = [manager.requestSerializer requestWithMethod:@"POST" URLString:finalURL parameters:parameters error:nil];
    
    NSString *jsonString;
    if(requestSerializerContentType){
        [request setValue:requestSerializerContentType forHTTPHeaderField:@"Content-Type"];
        
        if([requestSerializerContentType isEqualToString:@"application/x-www-form-urlencoded"]){
//            NSString *jsonString2;
            NSMutableString *dataStr2 = [NSMutableString new];

            NSDictionary *parametersData2 = parameters;
            if(parametersData2.allKeys.count>0){
                for (int i = 0; i < parametersData2.count;  i ++) {
                    NSString *key = parametersData2.allKeys[i];
                    id value = parametersData2[key];
                    [dataStr2 appendFormat:@"%@=%@&",key,value];
                }
                NSString *postStr = [dataStr2 substringWithRange:NSMakeRange(0, dataStr2.length - 1)];
                jsonString = postStr;
            }else{
                jsonString =[[NSString new] URLEncodedString];
            }
//            NSData *bodyData = [jsonString2 dataUsingEncoding:NSUTF8StringEncoding];//把bodyString转换为NSData数据
//            [request setHTTPBody:bodyData];
        }
        else{
            [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
            
            NSData *jsonData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
            jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
            if(kStringIsEmpty(jsonString)){
                jsonString = [NSString new];
            }
        }
        
    }else{
        [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
        
        NSData *jsonData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
        jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
        if(kStringIsEmpty(jsonString)){
            jsonString = [NSString new];
        }
    }
    

//    NSData *jsonData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
//    NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];

    NSData *bodyData = [jsonString dataUsingEncoding:NSUTF8StringEncoding];
    if(!bodyData){
        bodyData = [NSData new];
    }
    [request setHTTPBody:data2];
    
    NSURLSessionDataTask *task = [manager.session dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
        dispatch_async(dispatch_get_main_queue(), ^{
            if (error !=nil) {
                if (failure) {
                    failure(error);
                }
                
            }else{
                if (data) {
                    NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:nil];
                    [weakSelf successHandling:dict requestUrl:finalURL];
//                    NSLog(@"finalURL===%@\n请求响应：%@",finalURL,dict);
                    if (!dict) {
                        
#warning 暂时注释
#warning 暂时注释
#warning 暂时注释
#warning 暂时注释
//                        [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"token"];
//                        [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"cloudRootNodeID"];
//                        [[NSUserDefaults standardUserDefaults] synchronize];
//                        [[NSNotificationCenter defaultCenter] postNotificationName:@"authorLoginAccess" object:nil];

//                        [ZZMessageHud showMessage:@"登录失效，请重新登录" toView:[UIApplication sharedApplication].windows.firstObject];

                        NSDictionary *eroDict = @{@"code":@"401",@"msg":@"登录失效",@"data":@""};
                        if (success) {
                            success(eroDict);
                        }
                        return;
                    }
                    if (success) {
                        success(dict);
                    }
                    
                }
            }
        });
    }];
    [task resume];
    return task;
}

#pragma mark 把word解析成html文档
/**
 * 把word解析成html文档
 */
- (NSURLSessionDataTask *)WordParseToHtml:(NSString *)url
                      parameters:(id)parameters
             httpHeaderKeyValues:(NSDictionary *)header
       constructingBodyWithBlock:(void (^)(id <AFMultipartFormData> formData))formDataBlock
                         success:(void (^)(id responseObject))success
                         failure:(void (^)(NSError *error))failure {
    
    XSWeakSelf;
    
    
    
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
    
    /**
     *  可以接受的类型
     */
    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
    manager.requestSerializer = [AFJSONRequestSerializer serializer];
    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript", @"text/plain",@"text/html", nil];
    
    /**
     *  请求超时的时间
     */
    manager.requestSerializer.timeoutInterval = 100;

    
    [manager.requestSerializer setValue:@"multipart/form-data" forHTTPHeaderField:@"Content-Type"];
    
  
    NSString *token = [[NSUserDefaults standardUserDefaults] valueForKey:@"token"];
    if (token) {
        [manager.requestSerializer setValue:token  forHTTPHeaderField:@"Authorization"];
    }else{
        if([SSUserManager sharedUser].userModel.tempToken){
            token = [SSUserManager sharedUser].userModel.tempToken;
            NSLog(@"API_memberPlaceOrder--访客token==%@\n",token);
            
            [manager.requestSerializer setValue:token  forHTTPHeaderField:@"Authorization"];
        }
    }
    
    NSDictionary *finalParams = parameters;
    NSString *finalURL;
    if([url isEqualToString:API_userWechatQqParserWord]){
//    转换html接口：http://poi.writemall.com/user/wechatQqParserWord
        finalURL = [@"http://poi.writemall.com" stringByAppendingString:url];
    }else{
        finalURL = [API_Cloud_BASEURL stringByAppendingString:url];
    }
//    NSString *finalURL = [API_BASEURL stringByAppendingString:url];
    NSMutableString *paramStr = [NSMutableString stringWithString:finalURL];
    for (NSString *key in finalParams.allKeys) {
        if ([finalParams.allKeys indexOfObject:key] == 0) {
            [paramStr appendFormat:@"?%@=%@",key,finalParams[key]];
        } else {
            [paramStr appendFormat:@"&%@=%@",key,finalParams[key]];
        }
    }
    finalURL = paramStr;
    NSLog(@"请求的URL：%@",finalURL);
    NSURLSessionDataTask *task =[NSURLSessionDataTask new];// [manager POST:finalURL parameters:parameters constructingBodyWithBlock:^(id<AFMultipartFormData>  _Nonnull formData) {
//        if (formDataBlock) {
//            formDataBlock(formData);
//        }
//    } progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
//         NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:responseObject options:kNilOptions error:nil];
////        NSLog(@"finalURL===%@\n请求响应：%@",finalURL,dict);
//        if (success) {
//            success(dict);
//        }
//    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
//        if (failure) {
//            failure(error);
//        }
//    }];
    
    return task;
}

- (void)requestDELETEWithFullURLStr:(NSString *)finalURL paramDic:(NSDictionary *)paramDic Api_port:(NSString *)portStr finish:(void(^)(id responseObject))finish enError:(void(^)(NSError *error))enError{
 
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"text/html",@"application/json",@"text/javascript",@"text/json",@"text/plain", nil];
    
    // 设置请求头
    [manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Accept"];
//    [manager.requestSerializer setValue:api_key forHTTPHeaderField:@"api_key"];
    
    
    NSString *token = [[NSUserDefaults standardUserDefaults] valueForKey:@"token"];
    if (!kStringIsEmpty(token)) {
        [manager.requestSerializer setValue:token  forHTTPHeaderField:@"Authorization"];
    }else{
        if(!kStringIsEmpty([SSUserManager sharedUser].userModel.tempToken)){
            token = [SSUserManager sharedUser].userModel.tempToken;
            XSLog(@"API_memberPlaceOrder--访客token==%@\n",token);
            
            [manager.requestSerializer setValue:token  forHTTPHeaderField:@"Authorization"];
        }else{
            
            [manager.requestSerializer setValue:@"Basic Y2xpZW50LWFwOjFxYXp4c3cy" forHTTPHeaderField:@"Authorization"];
        }
    }
    
    
 
//    NSData *jsonData = [NSJSONSerialization dataWithJSONObject:paramDic options:0 error:nil];
//    NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
//    if(kStringIsEmpty(jsonString)){
//        jsonString = [NSString new];
//    }
//
    

////    NSData *jsonData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
////    NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
//
//    NSData *bodyData = [jsonString dataUsingEncoding:NSUTF8StringEncoding];
//    if(!bodyData){
//        bodyData = [NSData new];
//    }
//    [manager.requestSerializer.HTTPRequestHeaders setHTTPBody:bodyData];
//
//    NSString *finalURL = [API_BASEURL stringByAppendingString:url];
//    XSLog(@"请求的URL：%@",finalURL);
//    NSString *TempFinalURL = [API_BASEURL stringByAppendingString:portStr];
//    NSString *finalURL = [NSString stringWithFormat:@"%@%@",TempFinalURL,url];
    XSLog(@"请求的URL：%@",finalURL);
    
    
    
//[manager DELETE:finalURL parameters:paramDic success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
////        NSString *errcode = [NSString stringWithFormat:@"%@",[responseObject objectForKey:@"errcode"]];
////
////        if ([errcode isEqualToString:@"0"]) {
////
////            finish(responseObject);
////
////        }else{
////            NSString *errmsg = [responseObject objectForKey:@"errmsg"];
////        }
//    finish(responseObject);
//} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
//    enError(error);
//}];
    
    
//    NSString *finalURL = [touristsRegister_BASEURL stringByAppendingString:url];
//    XSLog(@"请求的URL：%@",finalURL);
    NSMutableURLRequest * request = [manager.requestSerializer requestWithMethod:@"DELETE" URLString:finalURL parameters:paramDic error:nil];
    
    NSString *jsonString;
    
        [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
        
        NSData *jsonData = [NSJSONSerialization dataWithJSONObject:paramDic options:0 error:nil];
        jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
        if(kStringIsEmpty(jsonString)){
            jsonString = [NSString new];
        }
    
    

//    NSData *jsonData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
//    NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];

    NSData *bodyData = [jsonString dataUsingEncoding:NSUTF8StringEncoding];
    if(!bodyData){
        bodyData = [NSData new];
    }
    [request setHTTPBody:bodyData];
    XSWeakSelf;
    NSURLSessionDataTask *task = [manager.session dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
        
        XSLog(@"url==%@ error---27272727==%@\n",finalURL,error.description);
        dispatch_async(dispatch_get_main_queue(), ^{
            if (error !=nil) {
                if (enError) {
                    enError(error);
                }
                
            }else{
                if (data) {
                    NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:nil];
                    [weakSelf successHandling:dict requestUrl:finalURL];
//                    XSLog(@"finalURL===%@\n请求响应：%@",finalURL,dict);
                    if (!dict) {
                        
#warning 暂时注释
#warning 暂时注释
#warning 暂时注释
#warning 暂时注释
//                        [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"token"];
//                        [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"cloudRootNodeID"];
//                        [[NSUserDefaults standardUserDefaults] synchronize];
//                        [[NSNotificationCenter defaultCenter] postNotificationName:@"authorLoginAccess" object:nil];

//                        [ZZMessageHud showMessage:@"登录失效，请重新登录" toView:[UIApplication sharedApplication].windows.firstObject];

                        NSDictionary *eroDict = @{@"code":@"401",@"msg":@"登录失效",@"data":@""};
                        if (finish) {
                            finish(eroDict);
                        }
                        return;
                    }
                    if (finish) {
                        finish(dict);
                    }
                    
                }
            }
        });
    }];
    [task resume];
    
}

#pragma mark - 同步到云
- (NSURLSessionDataTask *)POSTBodyFullUrlCloud:(NSString *)finalURL parameters:(id)parameters contentTyp:(NSString *)contentTpStr success:(void (^)(id _Nonnull))success failure:(void (^)(NSError * _Nonnull))failure {
    
    XSWeakSelf;
    
    
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
        
    /**
     *  可以接受的类型
     */
    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
    [manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Accept"];


    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript", nil];
    
    NSLog(@"请求的URL：%@",finalURL);
    
    
//    NSData *bodyData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
//    NSData *bodyData = [[bodyString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]dataUsingEncoding:NSUTF8StringEncoding];//把bodyString转换为NSData数据
    NSURL *serverUrl = [NSURL URLWithString:finalURL];//获取到服务器的url地址
    NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:serverUrl
                                                           cachePolicy:NSURLRequestReloadIgnoringLocalCacheData
                                                       timeoutInterval:60];//请求这个地址， timeoutInterval:10 设置为10s超时：请求时间超过10s会被认为连接不上，连接超时
    
    if(notNillStr(contentTpStr)){
        [request setValue:contentTpStr forHTTPHeaderField:@"Content-Type"];
    }
    else{
        [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
    }
     
    
    
    NSString *jsonString2;
    NSMutableString *dataStr2 = [NSMutableString new];

    NSDictionary *parametersData2 = parameters;
    if(parametersData2.allKeys.count>0){
        for (int i = 0; i < parametersData2.count;  i ++) {
            NSString *key = parametersData2.allKeys[i];
            id value = parametersData2[key];
            [dataStr2 appendFormat:@"%@=%@&",key,value];
        }
        NSString *postStr = [dataStr2 substringWithRange:NSMakeRange(0, dataStr2.length - 1)];
        jsonString2 = postStr;
    }else{
        jsonString2 =[[NSString new] URLEncodedString];
    }
    NSData *bodyData = [jsonString2 dataUsingEncoding:NSUTF8StringEncoding];//把bodyString转换为NSData数据
    
    
    [request setHTTPMethod:@"POST"];//POST请求
    [request setHTTPBody:bodyData];//body 数据
//    [request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"content-type"];//请求头
//    NSData *returnData = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];//同步发送request，成功后会得到服务器返回的数据
//    //返回的数据 根据系统的不同会返回不同编码的数据，比如windows 为GBK，Ubuntu 为UTF8.。。
    //注意转换编码格式
    
    
    NSString *token = [[NSUserDefaults standardUserDefaults] valueForKey:@"token"];
    if (token) {
        [request setValue:token  forHTTPHeaderField:@"Authorization"];
    }else{
        if([SSUserManager sharedUser].userModel.tempToken){
            token = [SSUserManager sharedUser].userModel.tempToken;
            NSLog(@"API_memberPlaceOrder--访客token==%@\n",token);
            
            [request setValue:token  forHTTPHeaderField:@"Authorization"];
        }else{
            
            [request setValue:@"Basic Y2xpZW50LWFwOjFxYXp4c3cy" forHTTPHeaderField:@"Authorization"];
        }
    }

    
    [request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"content-type"];//请求头
    
    NSURLSessionDataTask *task = [manager.session dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
        dispatch_async(dispatch_get_main_queue(), ^{
            if (error !=nil) {
                if (failure) {
                    failure(error);
                }
                
            }else{
                if (data) {
                    NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:nil];
                    [weakSelf successHandling:dict requestUrl:finalURL];
//                    NSLog(@"finalURL===%@\n请求响应：%@",finalURL,dict);
                    if (!dict) {
                        
#warning 暂时注释
#warning 暂时注释
#warning 暂时注释
#warning 暂时注释
//                        [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"token"];
//                        [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"cloudRootNodeID"];
//                        [[NSUserDefaults standardUserDefaults] synchronize];
//                        [[NSNotificationCenter defaultCenter] postNotificationName:@"authorLoginAccess" object:nil];

//                        [ZZMessageHud showMessage:@"登录失效，请重新登录" toView:[UIApplication sharedApplication].windows.firstObject];

                        NSDictionary *eroDict = @{@"code":@"401",@"msg":@"登录失效",@"data":@""};
                        if (success) {
                            success(eroDict);
                        }
                        return;
                    }
                    if (success) {
                        success(dict);
                    }
                    
                }
            }
        });
    }];
    [task resume];
    return task;
    
    

}
- (NSURLSessionDataTask *)POSTBodyFullUrl:(NSString *)finalURL withrequestSerializerContentType:(NSString *)requestSerializerContentType parameters:(id)parameters success:(void (^)(id _Nonnull responseObject))success failure:(void (^)(NSError * _Nonnull error))failure {
    
    XSWeakSelf;
    
    
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
        
    /**
     *  可以接受的类型
     */
    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
    [manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Accept"];


    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript", nil];
    
    if(requestSerializerContentType){
        [manager.requestSerializer setValue:requestSerializerContentType forHTTPHeaderField:@"Content-Type"];
    }else{
        [manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
    }
//    [manager.requestSerializer setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
    /**
     *  请求超时的时间
     */
    manager.requestSerializer.timeoutInterval = 100;
    NSString *token = [[NSUserDefaults standardUserDefaults] valueForKey:@"token"];
    
    NSMutableURLRequest * request = [manager.requestSerializer requestWithMethod:@"POST" URLString:finalURL parameters:parameters error:nil];
    if (token) {
        [manager.requestSerializer setValue:token  forHTTPHeaderField:@"Authorization"];
//        NSLog(@"API_memberPlaceOrder--用户token==%@\n",token);
        NSString *temptoken = [token stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
        
        temptoken = [temptoken stringByReplacingOccurrencesOfString:@" " withString:@""];
        if([temptoken isEqualToString:@"bearer "]||[temptoken isEqualToString:@"bearer"])
        {
            [manager.requestSerializer setValue:@"Basic Y2xpZW50LWFwOjFxYXp4c3cy" forHTTPHeaderField:@"Authorization"];
            
            [request setValue:@"Basic Y2xpZW50LWFwOjFxYXp4c3cy" forHTTPHeaderField:@"Authorization"];
        }
        else{
            [manager.requestSerializer setValue:temptoken  forHTTPHeaderField:@"Authorization"];
            
            [request setValue:temptoken forHTTPHeaderField:@"Authorization"];
        }
    }else{
        if([SSUserManager sharedUser].userModel.tempToken){
            token = [SSUserManager sharedUser].userModel.tempToken;
//            NSLog(@"API_memberPlaceOrder--访客token==%@\n",token);
            
            [manager.requestSerializer setValue:token  forHTTPHeaderField:@"Authorization"];
            
            [request setValue:token forHTTPHeaderField:@"Authorization"];
        }
        else{
            [manager.requestSerializer setValue:@"Basic Y2xpZW50LWFwOjFxYXp4c3cy"  forHTTPHeaderField:@"Authorization"];
            
            [request setValue:@"Basic Y2xpZW50LWFwOjFxYXp4c3cy" forHTTPHeaderField:@"Authorization"];
        }
    }
    
//    NSString *finalURL = [API_BASEURL stringByAppendingString:url];
    
    
//    NSString *jsonString2;
//    NSMutableString *dataStr2 = [NSMutableString new];
//
//    NSDictionary *parametersData2 = parameters;
//    if(parametersData2.allKeys.count>0){
//        for (int i = 0; i < parametersData2.count;  i ++) {
//            NSString *key = parametersData2.allKeys[i];
//            id value = parametersData2[key];
//            [dataStr2 appendFormat:@"%@=%@&",key,value];
//        }
//        NSString *postStr = [dataStr2 substringWithRange:NSMakeRange(0, dataStr2.length - 1)];
//        jsonString2 = [postStr URLEncodedString];
//    }else{
//        jsonString2 =[[NSString new] URLEncodedString];
//    }
//    finalURL = [NSString stringWithFormat:@"%@?%@",finalURL,jsonString2];
    
    
    NSLog(@"请求的URL：%@",finalURL);
    
    
    NSString *jsonString;
    if(requestSerializerContentType){
        [request setValue:requestSerializerContentType forHTTPHeaderField:@"Content-Type"];
        
        
        NSMutableString *dataStr = [NSMutableString new];
       
        NSDictionary *parametersData = parameters;
        if([parametersData isKindOfClass:[NSDictionary class]]){
//            if(parametersData.allKeys.count>0){
//                for (int i = 0; i < parametersData.count;  i ++) {
//                    NSString *key = parametersData.allKeys[i];
//                    id value = parametersData[key];
//                    [dataStr appendFormat:@"%@=%@&",key,value];
//                }
//                NSString *postStr = [dataStr substringWithRange:NSMakeRange(0, dataStr.length - 1)];
//                jsonString = postStr;
//            }else{
//                jsonString =[NSString new];
//            }
           jsonString = [NSString convertToJsonData:parametersData];
        }
        else{
            jsonString =[NSString new];
        }
        
    }else{
        [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
        
        NSData *jsonData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
        jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
        if(kStringIsEmpty(jsonString)){
            jsonString = [NSString new];
        }
    }
    

//    NSData *jsonData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
//    NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];

    NSData *bodyData = [jsonString dataUsingEncoding:NSUTF8StringEncoding];
    if(!bodyData){
        bodyData = [NSData new];
    }
    [request setHTTPBody:bodyData];
    
    
    NSURLSessionDataTask *task = [manager.session dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
        dispatch_async(dispatch_get_main_queue(), ^{
            if (error !=nil) {
                if (failure) {
                    failure(error);
                }
                
            }else{
                if (data) {
                    NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:nil];
                    [weakSelf successHandling:dict requestUrl:finalURL];
//                    NSLog(@"finalURL===%@\n请求响应：%@",finalURL,dict);
                    if (!dict) {
                        
#warning 暂时注释
#warning 暂时注释
#warning 暂时注释
#warning 暂时注释
//                        [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"token"];
//                        [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"cloudRootNodeID"];
//                        [[NSUserDefaults standardUserDefaults] synchronize];
//                        [[NSNotificationCenter defaultCenter] postNotificationName:@"authorLoginAccess" object:nil];

//                        [ZZMessageHud showMessage:@"登录失效，请重新登录" toView:[UIApplication sharedApplication].windows.firstObject];

                        NSDictionary *eroDict = @{@"code":@"401",@"msg":@"登录失效",@"data":@""};
                        if (success) {
                            success(eroDict);
                        }
                        return;
                    }
                    if (success) {
                        success(dict);
                    }
                    
                }
            }
        });
    }];
    [task resume];
    return task;
}
- (NSURLSessionDataTask *)POSTBodyFullUrl:(NSString *)finalURL parameters:(id)parameters success:(void (^)(id _Nonnull))success failure:(void (^)(NSError * _Nonnull))failure {
    
    XSWeakSelf;
    
    
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
        
    /**
     *  可以接受的类型
     */
    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
    [manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Accept"];


    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript", nil];
    [manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
//    [manager.requestSerializer setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
    
    
    
    
    /**
     *  请求超时的时间
     */
    manager.requestSerializer.timeoutInterval = 100;
    NSString *token = [[NSUserDefaults standardUserDefaults] valueForKey:@"token"];
    if (token) {
        [manager.requestSerializer setValue:token  forHTTPHeaderField:@"Authorization"];
    }else{
        if([SSUserManager sharedUser].userModel.tempToken){
            token = [SSUserManager sharedUser].userModel.tempToken;
            NSLog(@"API_memberPlaceOrder--访客token==%@\n",token);
            
            [manager.requestSerializer setValue:token  forHTTPHeaderField:@"Authorization"];
        }else{
            
            [manager.requestSerializer setValue:@"Basic Y2xpZW50LWFwOjFxYXp4c3cy" forHTTPHeaderField:@"Authorization"];
        }
    }
    
//    NSString *finalURL = [API_BASEURL stringByAppendingString:url];
    NSLog(@"请求的URL：%@",finalURL);
    NSMutableURLRequest * request = [manager.requestSerializer requestWithMethod:@"POST" URLString:finalURL parameters:parameters error:nil];
    NSData *jsonData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
    NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
    NSLog(@"\n\njsonString==\n\n%@\n\n",jsonString);
    NSData *bodyData = [jsonString dataUsingEncoding:NSUTF8StringEncoding];
    [request setHTTPBody:bodyData];
    request.HTTPMethod = @"POST";
    NSURLSessionDataTask *task = [manager.session dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
        dispatch_async(dispatch_get_main_queue(), ^{
            if (error !=nil) {
                if (failure) {
                    failure(error);
                }
                
            }else{
                if (data) {
                    NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:nil];
                    [weakSelf successHandling:dict requestUrl:finalURL];
//                    NSLog(@"finalURL===%@\n请求响应：%@",finalURL,dict);
                    if (!dict) {
                        
#warning 暂时注释
#warning 暂时注释
#warning 暂时注释
#warning 暂时注释
//                        [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"token"];
//                        [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"cloudRootNodeID"];
//                        [[NSUserDefaults standardUserDefaults] synchronize];
//                        [[NSNotificationCenter defaultCenter] postNotificationName:@"authorLoginAccess" object:nil];

//                        [ZZMessageHud showMessage:@"登录失效，请重新登录" toView:[UIApplication sharedApplication].windows.firstObject];

                        NSDictionary *eroDict = @{@"code":@"401",@"msg":@"登录失效",@"data":@""};
                        if (success) {
                            success(eroDict);
                        }
                        return;
                    }
                    if (success) {
                        success(dict);
                    }
                    
                }
            }
        });
    }];
    [task resume];
    return task;
}


- (NSURLSessionDataTask *)POSTBodyFullUrl:(NSString *)finalURL parameters:(id)parameters contentTyp:(NSString *)contentTpStr success:(void (^)(id _Nonnull))success failure:(void (^)(NSError * _Nonnull))failure {
    
    XSWeakSelf;
    
    
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
        
    /**
     *  可以接受的类型
     */
    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
    [manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Accept"];


    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript", nil];
    
//    [manager.requestSerializer setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
    
    
    
    /**
     *  请求超时的时间
     */
    manager.requestSerializer.timeoutInterval = 100;
    NSString *token = [[NSUserDefaults standardUserDefaults] valueForKey:@"token"];
    NSLog(@"token==%@\n",token);
    if (!kStringIsEmpty(token)) {
        if([token isEqualToString:@"bearer "]||[token isEqualToString:@"bearer"])
        {
            [manager.requestSerializer setValue:@"Basic Y2xpZW50LWFwOjFxYXp4c3cy" forHTTPHeaderField:@"Authorization"];
        }
        else{
            [manager.requestSerializer setValue:token  forHTTPHeaderField:@"Authorization"];
        }
        
    }else{
        if([SSUserManager sharedUser].userModel.tempToken){
            token = [SSUserManager sharedUser].userModel.tempToken;
            NSLog(@"API_memberPlaceOrder--访客token==%@\n",token);

            [manager.requestSerializer setValue:token  forHTTPHeaderField:@"Authorization"];
        }else{

            [manager.requestSerializer setValue:@"Basic Y2xpZW50LWFwOjFxYXp4c3cy" forHTTPHeaderField:@"Authorization"];
        }
    }
    
//    NSString *finalURL = [API_BASEURL stringByAppendingString:url];
    NSLog(@"请求的URL：%@",finalURL);
    
    NSMutableURLRequest * request = [manager.requestSerializer requestWithMethod:@"POST" URLString:finalURL parameters:parameters error:nil];
    
    
    
    if([contentTpStr isEqualToString:@"application/x-www-form-urlencoded"]){
        NSString *jsonString2;
        NSMutableString *dataStr2 = [NSMutableString new];

        NSDictionary *parametersData2 = parameters;
        if(parametersData2.allKeys.count>0){
            for (int i = 0; i < parametersData2.count;  i ++) {
                NSString *key = parametersData2.allKeys[i];
                id value = parametersData2[key];
                [dataStr2 appendFormat:@"%@=%@&",key,value];
            }
            NSString *postStr = [dataStr2 substringWithRange:NSMakeRange(0, dataStr2.length - 1)];
            jsonString2 = postStr;
        }else{
            jsonString2 =[[NSString new] URLEncodedString];
        }
        NSData *bodyData = [jsonString2 dataUsingEncoding:NSUTF8StringEncoding];//把bodyString转换为NSData数据
        [request setHTTPBody:bodyData];
    }
    else{
        NSData *jsonData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
        NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
        NSLog(@"\n\njsonString==\n\n%@\n\n",jsonString);
        NSData *bodyData = [jsonString dataUsingEncoding:NSUTF8StringEncoding];
        [request setHTTPBody:bodyData];
        
    }
    
    request.HTTPMethod = @"POST";

    if(notNillStr(contentTpStr)){
        [request setValue:contentTpStr forHTTPHeaderField:@"Content-Type"];
    }
    else{
        [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
    }
    if(notNillStr(contentTpStr)){
        [manager.requestSerializer setValue:contentTpStr forHTTPHeaderField:@"Content-Type"];
    }
    else{
        [manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
    }

    NSURLSessionDataTask *task = [manager.session dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
        dispatch_async(dispatch_get_main_queue(), ^{
            if (error !=nil) {
                if (failure) {
                    failure(error);
                }

            }else{
                if (data) {
                    NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:nil];
                    [weakSelf successHandling:dict requestUrl:finalURL];
//                    NSLog(@"finalURL===%@\n请求响应：%@",finalURL,dict);
                    if (!dict) {

#warning 暂时注释
#warning 暂时注释
#warning 暂时注释
#warning 暂时注释
//                        [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"token"];
//                        [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"cloudRootNodeID"];
//                        [[NSUserDefaults standardUserDefaults] synchronize];
//                        [[NSNotificationCenter defaultCenter] postNotificationName:@"authorLoginAccess" object:nil];

//                        [ZZMessageHud showMessage:@"登录失效，请重新登录" toView:[UIApplication sharedApplication].windows.firstObject];

                        NSDictionary *eroDict = @{@"code":@"401",@"msg":@"登录失效",@"data":@""};
                        if (success) {
                            success(eroDict);
                        }
                        return;
                    }
                    if (success) {
                        success(dict);
                    }

                }
            }
        });
    }];
    [task resume];
    return task;
    
    

}

// 成语发送验证码
- (NSURLSessionDataTask *)POSTBodyWithFinalUrl:(NSString *)finalURL parameters:(id)parameters success:(void (^)(id _Nonnull))success failure:(void (^)(NSError * _Nonnull))failure {
    
    XSWeakSelf;
    
    
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
        
    /**
     *  可以接受的类型
     */
    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
    [manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Accept"];


    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript", nil];
    [manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
//    [manager.requestSerializer setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
    
    
    
    
    /**
     *  请求超时的时间
     */
    manager.requestSerializer.timeoutInterval = 100;
    NSString *token = [[NSUserDefaults standardUserDefaults] valueForKey:@"token"];
    if (token) {
        [manager.requestSerializer setValue:token  forHTTPHeaderField:@"Authorization"];
    }else{
        if([SSUserManager sharedUser].userModel.tempToken){
            token = [SSUserManager sharedUser].userModel.tempToken;
            NSLog(@"API_memberPlaceOrder--访客token==%@\n",token);
            
            [manager.requestSerializer setValue:token  forHTTPHeaderField:@"Authorization"];
        }else{
            
            [manager.requestSerializer setValue:@"Basic Y2xpZW50LWFwOjFxYXp4c3cy" forHTTPHeaderField:@"Authorization"];
        }
    }
    
//    NSString *finalURL = [API_BASEURL stringByAppendingString:url];
    NSLog(@"请求的URL：%@",finalURL);
    NSMutableURLRequest * request = [manager.requestSerializer requestWithMethod:@"POST" URLString:finalURL parameters:parameters error:nil];
    NSData *jsonData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
    NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
    NSLog(@"\n\njsonString==\n\n%@\n\n",jsonString);
    NSData *bodyData = [jsonString dataUsingEncoding:NSUTF8StringEncoding];
    [request setHTTPBody:bodyData];
    request.HTTPMethod = @"POST";
    NSURLSessionDataTask *task = [manager.session dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
        dispatch_async(dispatch_get_main_queue(), ^{
            if (error !=nil) {
                if (failure) {
                    failure(error);
                }
                
            }else{
                if (data) {
                    NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:nil];
                    [weakSelf successHandling:dict requestUrl:finalURL];
//                    NSLog(@"finalURL===%@\n请求响应：%@",finalURL,dict);
                    if (!dict) {
                        
#warning 暂时注释
#warning 暂时注释
#warning 暂时注释
#warning 暂时注释
//                        [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"token"];
//                        [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"cloudRootNodeID"];
//                        [[NSUserDefaults standardUserDefaults] synchronize];
//                        [[NSNotificationCenter defaultCenter] postNotificationName:@"authorLoginAccess" object:nil];

//                        [ZZMessageHud showMessage:@"登录失效，请重新登录" toView:[UIApplication sharedApplication].windows.firstObject];

                        NSDictionary *eroDict = @{@"code":@"401",@"msg":@"登录失效",@"data":@""};
                        if (success) {
                            success(eroDict);
                        }
                        return;
                    }
                    if (success) {
                        success(dict);
                    }
                    
                }
            }
        });
    }];
    [task resume];
    return task;
}
- (void)GETBodyForDataFullUrl:(NSString *)finalURL withrequestSerializerContentType:(NSString *)requestSerializerContentType parameters:(id)parameters  withMimeType:(NSString *)mimeTypeStr progress:(nullable void (^)(NSProgress * _Nonnull))uploadProgre success:(void (^)(id _Nonnull sucee))success failure:(void (^)(NSError * _Nonnull err))failure {
    
    XSWeakSelf;
    
    
    
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
        
    /**
     *  可以接受的类型
     */
    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
    [manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Accept"];


    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript", nil];
    
    if(requestSerializerContentType){
        [manager.requestSerializer setValue:requestSerializerContentType forHTTPHeaderField:@"Content-Type"];
    }else{
        [manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
    }
//    [manager.requestSerializer setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
    /**
     *  请求超时的时间
     */
    manager.requestSerializer.timeoutInterval = 100;
    NSString *token = [[NSUserDefaults standardUserDefaults] valueForKey:@"token"];
    if (token) {
        [manager.requestSerializer setValue:token  forHTTPHeaderField:@"Authorization"];
//        NSLog(@"API_memberPlaceOrder--用户token==%@\n",token);
    }else{
        if([SSUserManager sharedUser].userModel.tempToken){
            token = [SSUserManager sharedUser].userModel.tempToken;
//            NSLog(@"API_memberPlaceOrder--访客token==%@\n",token);
            
            [manager.requestSerializer setValue:token  forHTTPHeaderField:@"Authorization"];
        }
        else{
            [manager.requestSerializer setValue:@"Basic Y2xpZW50LWFwOjFxYXp4c3cy"  forHTTPHeaderField:@"Authorization"];
        }
    }
    
    
    
//    NSString *finalURL = [API_BASEURL stringByAppendingString:url];
//    NSLog(@"请求的URL：%@",finalURL);
    
//    NSString *TempFinalURL = [API_BASEURL stringByAppendingString:portStr];
//    NSString *finalURL = [NSString stringWithFormat:@"%@%@",TempFinalURL,URLStr];
    

//    NSMutableString *dataStr = [NSMutableString new];
//    NSDictionary *parametersData = parameters;
//    if(parametersData.allKeys.count>0){
//        for (int i = 0; i < parametersData.count;  i ++) {
//            NSString *key = parametersData.allKeys[i];
//            id value = parametersData[key];
//            [dataStr appendFormat:@"%@=%@&",key,value];
//        }
//        NSString *postStr = [dataStr substringWithRange:NSMakeRange(0, dataStr.length - 1)];
//        finalURL = [NSString stringWithFormat:@"%@?%@",finalURL,postStr];
//    }
    
    NSLog(@"请求的URL：%@",finalURL);
    
    if(mimeTypeStr==nil||mimeTypeStr.length==0){
        mimeTypeStr = @"image/png";
    }
    
    [manager POST:finalURL parameters:parameters headers:@{} constructingBodyWithBlock:^(id<AFMultipartFormData>  _Nonnull formData) {
        
        NSData *imgData = [@"tempStr" dataUsingEncoding:NSUTF8StringEncoding];//[NSData alloc];//UIImagePNGRepresentation(tpImg);
        NSDateFormatter *formatter =[[NSDateFormatter alloc] init];
        [formatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
        NSString *dString = [formatter stringFromDate:[NSDate date]];

        NSString *fileNameStr = [NSString stringWithFormat:@"file001%@",dString];
        [formData appendPartWithFileData:imgData name:@"name" fileName:fileNameStr mimeType:@"image/png"];
        
    } progress:^(NSProgress * _Nonnull uploadProgress) {
        uploadProgre(uploadProgress);
    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
//        success(responseObject);
//        if (error !=nil) {
//            if (failure) {
//                failure(error);
//            }
//
//        }else{
            if ([responseObject isKindOfClass:[NSData class]]) {
                NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:responseObject options:kNilOptions error:nil];
                [weakSelf successHandling:dict requestUrl:finalURL];
                
                
//                    NSDictionary *dddd = [NSDictionary yy_modelWithJSON:data];
//                    NSLog(@"finalURL==%@\n请求响应：%@",finalURL,temppStr);
//                    NSLog(@"dddd==%@\n",dddd);
                if (!dict) {
                    
#warning 暂时注释
#warning 暂时注释
#warning 暂时注释
#warning 暂时注释
//                        [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"token"];
//                        [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"cloudRootNodeID"];
//                        [[NSUserDefaults standardUserDefaults] synchronize];
//                        [[NSNotificationCenter defaultCenter] postNotificationName:@"authorLoginAccess" object:nil];

//                        [ZZMessageHud showMessage:@"登录失效，请重新登录" toView:[UIApplication sharedApplication].windows.firstObject];
                    
//                    NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)response;
//                    NSString *strCode = [NSString stringWithFormat:@"%ld",httpResponse.statusCode];
//                    if(!notNillStr(strCode)){
//                        strCode =@"401";
//                    }
//                    NSDictionary *eroDict = @{@"code":strCode,@"msg":@"登录失效",@"data":@""};
//                    NSString *temppStr = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
//                    if(temppStr){
//                        eroDict = @{@"code":@"401",@"msg":@"返回有误",@"data":temppStr};
//                    }
                    if (success) {
                        success(@{@"code":@"401",@"msg":@"返回有误",@"data":@"返回有误"});
                    }
                    return;
                }
                if (success) {
                    success(dict);
                }
                
            }
            else{
                if (success) {
                    success(responseObject);
                }
            }
//        }
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        failure(error);
    }];
}

- (NSURLSessionDataTask *)GETBodyFullUrl:(NSString *)finalURL withrequestSerializerContentType:(NSString *)requestSerializerContentType parameters:(id)parameters success:(void (^)(id _Nonnull sucee))success failure:(void (^)(NSError * _Nonnull err))failure {
    
    XSWeakSelf;
    
    
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
        
    /**
     *  可以接受的类型
     */
    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
    [manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Accept"];


    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript", nil];
    
    if(requestSerializerContentType){
        [manager.requestSerializer setValue:requestSerializerContentType forHTTPHeaderField:@"Content-Type"];
    }else{
        [manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
    }
//    [manager.requestSerializer setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
    /**
     *  请求超时的时间
     */
    manager.requestSerializer.timeoutInterval = 100;
    NSString *token = [[NSUserDefaults standardUserDefaults] valueForKey:@"token"];
    if (token) {
        [manager.requestSerializer setValue:token  forHTTPHeaderField:@"Authorization"];
        NSLog(@"API_memberPlaceOrder--用户token==%@\n",token);
    }else{
        if([SSUserManager sharedUser].userModel.tempToken){
            token = [SSUserManager sharedUser].userModel.tempToken;
            NSLog(@"API_memberPlaceOrder--访客token==%@\n",token);
            
            [manager.requestSerializer setValue:token  forHTTPHeaderField:@"Authorization"];
        }
    }
    
    
//    NSString *TempFinalURL = [API_BASEURL stringByAppendingString:portStr];
//    NSString *finalURL = [NSString stringWithFormat:@"%@%@",TempFinalURL,url];
    NSLog(@"请求的URL：%@",finalURL);
    NSMutableURLRequest * request = [manager.requestSerializer requestWithMethod:@"GET" URLString:finalURL parameters:parameters error:nil];
    request.HTTPMethod = @"GET";
    NSString *jsonString;
    if(requestSerializerContentType){
        [request setValue:requestSerializerContentType forHTTPHeaderField:@"Content-Type"];
        
        
        NSMutableString *dataStr = [NSMutableString new];
       
        NSDictionary *parametersData = parameters;
        if(parametersData.allKeys.count>0){
            for (int i = 0; i < parametersData.count;  i ++) {
                NSString *key = parametersData.allKeys[i];
                id value = parametersData[key];
                [dataStr appendFormat:@"%@=%@&",key,value];
            }
            NSString *postStr = [dataStr substringWithRange:NSMakeRange(0, dataStr.length - 1)];
            jsonString = postStr;
        }else{
            jsonString =[NSString new];
        }
        
    }else{
        [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
        
        NSData *jsonData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
        jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
        if(kStringIsEmpty(jsonString)){
            jsonString = [NSString new];
        }
    }
    

//    NSData *jsonData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
//    NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];

//    NSData *bodyData = [jsonString dataUsingEncoding:NSUTF8StringEncoding];
//    if(!bodyData){
//        bodyData = [NSData new];
//    }
//    [request setHTTPBody:bodyData];
    
    NSURLSessionDataTask *task = [manager.session dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
        dispatch_async(dispatch_get_main_queue(), ^{
            if (error !=nil) {
                if (failure) {
                    failure(error);
                }
                
            }else{
                if (data) {
                    NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:nil];
                   
                    [weakSelf successHandling:dict requestUrl:finalURL];
                    
//                    NSDictionary *dddd = [NSDictionary yy_modelWithJSON:data];
//                    NSLog(@"finalURL==%@\n请求响应：%@",finalURL,temppStr);
//                    NSLog(@"dddd==%@\n",dddd);
                    if (!dict) {
                        
#warning 暂时注释
#warning 暂时注释
#warning 暂时注释
#warning 暂时注释
//                        [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"token"];
//                        [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"cloudRootNodeID"];
//                        [[NSUserDefaults standardUserDefaults] synchronize];
//                        [[NSNotificationCenter defaultCenter] postNotificationName:@"authorLoginAccess" object:nil];

//                        [ZZMessageHud showMessage:@"登录失效，请重新登录" toView:[UIApplication sharedApplication].windows.firstObject];
                        
                        NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)response;
                        NSString *strCode = [NSString stringWithFormat:@"%ld",httpResponse.statusCode];
                        if(!notNillStr(strCode)){
                            strCode =@"401";
                        }
                        NSDictionary *eroDict = @{@"code":strCode,@"msg":@"登录失效",@"data":@""};
                        NSString *temppStr = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
                        if(temppStr){
                            eroDict = @{@"code":strCode,@"msg":temppStr,@"data":temppStr};
                        }
                        if (success) {
                            success(eroDict);
                        }
                        return;
                    }
                    if (success) {
                        success(dict);
                    }
                    
                }
            }
        });
    }];
    [task resume];
    return task;
}
- (void)uploadFileWithFullUrl:(NSString *)finalURL withrequestSerializerContentType:(NSString *)requestSerializerContentType  withFileData:(NSData *)fData withFileName:(NSString *)fileNameStr withMimeType:(NSString *)mimeTypeStr withParame:(NSDictionary *)parameDict success:(void (^)(id _Nonnull responseObject))success progress:(nullable void (^)(NSProgress * _Nonnull))uploadProgre failure:(void (^)(NSError * _Nonnull error))failure {
    
    XSWeakSelf;
    
    
    
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
        
    /**
     *  可以接受的类型
     */
    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
    [manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Accept"];


    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript", nil];
    
    if(requestSerializerContentType){
        [manager.requestSerializer setValue:requestSerializerContentType forHTTPHeaderField:@"Content-Type"];
    }else{
        [manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
    }
//    [manager.requestSerializer setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
    /**
     *  请求超时的时间
     */
    manager.requestSerializer.timeoutInterval = 100;
    NSString *token = [[NSUserDefaults standardUserDefaults] valueForKey:@"token"];
    if (token) {
        [manager.requestSerializer setValue:token  forHTTPHeaderField:@"Authorization"];
//        NSLog(@"API_memberPlaceOrder--用户token==%@\n",token);
    }else{
        if([SSUserManager sharedUser].userModel.tempToken){
            token = [SSUserManager sharedUser].userModel.tempToken;
//            NSLog(@"API_memberPlaceOrder--访客token==%@\n",token);
            
            [manager.requestSerializer setValue:token  forHTTPHeaderField:@"Authorization"];
        }
        else{
            [manager.requestSerializer setValue:@"Basic Y2xpZW50LWFwOjFxYXp4c3cy"  forHTTPHeaderField:@"Authorization"];
        }
    }
    
    
    
//    NSString *finalURL = [API_BASEURL stringByAppendingString:url];
//    NSLog(@"请求的URL：%@",finalURL);
    
//    NSString *TempFinalURL = [API_BASEURL stringByAppendingString:portStr];
//    NSString *finalURL = [NSString stringWithFormat:@"%@%@",TempFinalURL,URLStr];
    NSLog(@"请求的URL：%@",finalURL);
    
    if(mimeTypeStr==nil||mimeTypeStr.length==0){
        mimeTypeStr = @"image/png";
    }
//    [manager POST:finalURL parameters:parameDict constructingBodyWithBlock:^(id<AFMultipartFormData>  _Nonnull formData) {
//
//        [formData appendPartWithFileData:fData name:@"upfile" fileName:fileNameStr mimeType:mimeTypeStr];
//        int a =  10;
//        } progress:^(NSProgress * _Nonnull uploadProgress) {
//            uploadProgre(uploadProgress);
//        } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
//            success(responseObject);
//        } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
//            failure(error);
//        }];
    [manager POST:finalURL parameters:parameDict headers:@{} constructingBodyWithBlock:^(id<AFMultipartFormData>  _Nonnull formData) {
        [formData appendPartWithFileData:fData name:@"upfile" fileName:fileNameStr mimeType:mimeTypeStr];
    } progress:^(NSProgress * _Nonnull uploadProgress) {
        uploadProgre(uploadProgress);
    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        success(responseObject);
        [weakSelf successHandling:responseObject requestUrl:finalURL];
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        failure(error);
    }];
}


- (void)uploadFileWithFullUrl:(NSString *)finalURL withServerFileName:(NSString *)serverFileName withrequestSerializerContentType:(NSString *)requestSerializerContentType  withFileData:(NSData *)fData withFileName:(NSString *)fileNameStr withMimeType:(NSString *)mimeTypeStr withParame:(NSDictionary *)parameDict success:(void (^)(id _Nonnull responseObject))success progress:(nullable void (^)(NSProgress * _Nonnull))uploadProgre failure:(void (^)(NSError * _Nonnull error))failure {
    
    XSWeakSelf;
    
    
    
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
        
    /**
     *  可以接受的类型
     */
    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
    [manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Accept"];


    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript", nil];
    
    if(requestSerializerContentType){
        [manager.requestSerializer setValue:requestSerializerContentType forHTTPHeaderField:@"Content-Type"];
    }else{
        [manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
    }
//    [manager.requestSerializer setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
    /**
     *  请求超时的时间
     */
    manager.requestSerializer.timeoutInterval = 100;
    NSString *token = [[NSUserDefaults standardUserDefaults] valueForKey:@"token"];
    if (token) {
        [manager.requestSerializer setValue:token  forHTTPHeaderField:@"Authorization"];
//        NSLog(@"API_memberPlaceOrder--用户token==%@\n",token);
    }else{
        if([SSUserManager sharedUser].userModel.tempToken){
            token = [SSUserManager sharedUser].userModel.tempToken;
//            NSLog(@"API_memberPlaceOrder--访客token==%@\n",token);
            
            [manager.requestSerializer setValue:token  forHTTPHeaderField:@"Authorization"];
        }
        else{
            [manager.requestSerializer setValue:@"Basic Y2xpZW50LWFwOjFxYXp4c3cy"  forHTTPHeaderField:@"Authorization"];
        }
    }
    
    
    
//    NSString *finalURL = [API_BASEURL stringByAppendingString:url];
//    NSLog(@"请求的URL：%@",finalURL);
    
//    NSString *TempFinalURL = [API_BASEURL stringByAppendingString:portStr];
//    NSString *finalURL = [NSString stringWithFormat:@"%@%@",TempFinalURL,URLStr];
    NSLog(@"请求的URL：%@",finalURL);
    
    if(mimeTypeStr==nil||mimeTypeStr.length==0){
        mimeTypeStr = @"image/png";
    }
//    [manager POST:finalURL parameters:parameDict constructingBodyWithBlock:^(id<AFMultipartFormData>  _Nonnull formData) {
//
//        [formData appendPartWithFileData:fData name:@"upfile" fileName:fileNameStr mimeType:mimeTypeStr];
//        int a =  10;
//        } progress:^(NSProgress * _Nonnull uploadProgress) {
//            uploadProgre(uploadProgress);
//        } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
//            success(responseObject);
//        } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
//            failure(error);
//        }];
    [manager POST:finalURL parameters:parameDict headers:@{} constructingBodyWithBlock:^(id<AFMultipartFormData>  _Nonnull formData) {
        [formData appendPartWithFileData:fData name:serverFileName fileName:fileNameStr mimeType:mimeTypeStr];
    } progress:^(NSProgress * _Nonnull uploadProgress) {
        uploadProgre(uploadProgress);
    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        success(responseObject);
        [weakSelf successHandling:responseObject requestUrl:finalURL];
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        failure(error);
    }];
}

- (NSURLSessionDataTask *)POSTBodyFullUrl:(NSString *)finalURL port:(NSString *)portStr parameters:(id)parameters success:(void (^)(id _Nonnull responseObject))success failure:(void (^)(NSError * _Nonnull error))failure {
    
    XSWeakSelf;
    
    
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
        
    /**
     *  可以接受的类型
     */
    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
    [manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Accept"];


    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript", nil];
    [manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
//    [manager.requestSerializer setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
    
    
    
    
    /**
     *  请求超时的时间
     */
    manager.requestSerializer.timeoutInterval = 100;
    NSString *token = [[NSUserDefaults standardUserDefaults] valueForKey:@"token"];
    if (token) {
        [manager.requestSerializer setValue:token  forHTTPHeaderField:@"Authorization"];
    }else{
        if([SSUserManager sharedUser].userModel.tempToken){
            token = [SSUserManager sharedUser].userModel.tempToken;
            NSLog(@"API_memberPlaceOrder--访客token==%@\n",token);
            
            [manager.requestSerializer setValue:token  forHTTPHeaderField:@"Authorization"];
        }else{
            
            [manager.requestSerializer setValue:@"Basic Y2xpZW50LWFwOjFxYXp4c3cy" forHTTPHeaderField:@"Authorization"];
        }
    }
    
//    NSString *finalURL = [API_BASEURL stringByAppendingString:url];
//    NSLog(@"请求的URL：%@",finalURL);
//    NSString *TempFinalURL = [API_BASEURL stringByAppendingString:portStr];
//    NSString *finalURL = [NSString stringWithFormat:@"%@%@",TempFinalURL,url];
    NSLog(@"请求的URL：%@",finalURL);
    
    NSMutableURLRequest * request = [manager.requestSerializer requestWithMethod:@"POST" URLString:finalURL parameters:parameters error:nil];
    NSData *jsonData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
    NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
    NSLog(@"\n\njsonString==\n\n%@\n\n",jsonString);
    NSData *bodyData = [jsonString dataUsingEncoding:NSUTF8StringEncoding];
    [request setHTTPBody:bodyData];
    request.HTTPMethod = @"POST";
    NSURLSessionDataTask *task = [manager.session dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
        
        NSLog(@"request--URL：%@",finalURL);
        dispatch_async(dispatch_get_main_queue(), ^{
            if (error !=nil) {
                if (failure) {
                    failure(error);
                }
                
            }else{
                
//                NSDictionary *dict22 = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:nil];
                
                
//                if (data) {
//                    NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:nil];
////                    NSLog(@"finalURL===%@\n请求响应：%@",finalURL,dict);
//                    if (!dict) {
                NSDictionary *tempDictData;
                        if (data) {
                            NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:nil];
        //                    NSLog(@"finalURL===%@\n请求响应：%@",finalURL,dict);
                            [weakSelf successHandling:dict requestUrl:finalURL];
                            if (dict) {
                                tempDictData = dict;
                            }
                            
                        }
                        
                        NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)response;
                        if(httpResponse.statusCode==200){
                            if (success) {
                                
                                if(tempDictData){
                                    success(@{@"message":@"成功",@"data":tempDictData,@"code":@"200"});
                                }else{
                                    success(@{@"message":@"成功",@"data":@"null",@"code":@"200"});
                                }
                            }
                        }
                        else{
                            
    #warning 暂时注释
    #warning 暂时注释
    #warning 暂时注释
    #warning 暂时注释
    //                        [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"token"];
    //                        [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"cloudRootNodeID"];
    //                        [[NSUserDefaults standardUserDefaults] synchronize];
    //                        [[NSNotificationCenter defaultCenter] postNotificationName:@"authorLoginAccess" object:nil];

//                            [ZZMessageHud showMessage:@"登录失效，请重新登录" toView:[UIApplication sharedApplication].windows.firstObject];
                            
                            NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)response;
                            if(httpResponse.statusCode==500){
                                NSDictionary *eroDict = @{@"code":@"500",@"msg":@"系统繁忙",@"data":@""};
                                if (success) {
                                    success(eroDict);
                                }
                                return;
                            }
                            else{
                                NSDictionary *eroDict = @{@"code":@"401",@"msg":@"登录失效",@"data":@""};
                                if (success) {
                                    success(eroDict);
                                }
                                return;
                            }

                            
                        }
//                    }
//                    if (success) {
//                        success(dict);
//                    }
//
//                }
            }
        });
    }];
    [task resume];
    return task;
}
- (NSURLSessionDataTask *)uploadFullUrl:(NSString *)url
                      parameters:(id)parameters
       constructingBodyWithBlock:(void (^)(id <AFMultipartFormData> formData))formDataBlock
                         success:(void (^)(id responseObject))success
                         failure:(void (^)(NSError *error))failure {
    
    XSWeakSelf;
    
    
    return [self uploadFullUrl:url parameters:parameters httpHeaderKeyValues:@{} constructingBodyWithBlock:formDataBlock success:success failure:failure];
}
/**
 *  上传文件
 */
- (NSURLSessionDataTask *)uploadFullUrl:(NSString *)finalURL
                      parameters:(id)parameters
             httpHeaderKeyValues:(NSDictionary *)header
       constructingBodyWithBlock:(void (^)(id <AFMultipartFormData> formData))formDataBlock
                         success:(void (^)(id responseObject))success
                         failure:(void (^)(NSError *error))failure {
    
    XSWeakSelf;
    
    
    
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
    
    /**
     *  可以接受的类型
     */
    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
    manager.requestSerializer = [AFJSONRequestSerializer serializer];
    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript", @"text/plain",@"text/html", nil];
    
    /**
     *  请求超时的时间
     */
    manager.requestSerializer.timeoutInterval = 100;

    
    [manager.requestSerializer setValue:@"multipart/form-data" forHTTPHeaderField:@"Content-Type"];
    
  
    NSString *token = [[NSUserDefaults standardUserDefaults] valueForKey:@"token"];
    if (token) {
        [manager.requestSerializer setValue:token  forHTTPHeaderField:@"Authorization"];
    }else{
        if([SSUserManager sharedUser].userModel.tempToken){
            token = [SSUserManager sharedUser].userModel.tempToken;
            NSLog(@"API_memberPlaceOrder--访客token==%@\n",token);
            
            [manager.requestSerializer setValue:token  forHTTPHeaderField:@"Authorization"];
        }
    }
    
    NSDictionary *finalParams = parameters;

//    NSString *TempFinalURL = [API_BASEURL stringByAppendingString:portStr];
//    NSString *finalURL = [NSString stringWithFormat:@"%@%@",TempFinalURL,url];
    
    
    NSMutableString *paramStr = [NSMutableString stringWithString:finalURL];
    for (NSString *key in finalParams.allKeys) {
        if ([finalParams.allKeys indexOfObject:key] == 0) {
            [paramStr appendFormat:@"?%@=%@",key,finalParams[key]];
        } else {
            [paramStr appendFormat:@"&%@=%@",key,finalParams[key]];
        }
    }
    finalURL = paramStr;
    NSLog(@"请求的URL：%@",finalURL);
    
    NSURLSessionDataTask *task = [manager POST:finalURL parameters:parameters headers:@{@"Authorization":token} constructingBodyWithBlock:^(id<AFMultipartFormData>  _Nonnull formData) {
        if (formDataBlock) {
            formDataBlock(formData);
        }
    } progress:^(NSProgress * _Nonnull uploadProgress) {
        
    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:responseObject options:kNilOptions error:nil];
        [weakSelf successHandling:dict requestUrl:finalURL];
//        NSLog(@"finalURL===%@\n请求响应：%@",finalURL,dict);
       if (success) {
           success(dict);
       }
   } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        if (failure) {
            failure(error);
        }
    }];
    return task;
}
- (void)uploadFileWithFullUrl3:(NSString *)finalURL Port:(NSString *)portStr withrequestSerializerContentType:(NSString *)requestSerializerContentType  withFileData:(NSData *)fData withFileName:(NSString *)fileNameStr withMimeType:(NSString *)mimeTypeStr withParame:(NSDictionary *)parameDict success:(void (^)(id _Nonnull responseObject))success progress:(nullable void (^)(NSProgress * _Nonnull))uploadProgre failure:(void (^)(NSError * _Nonnull error))failure {
    
    XSWeakSelf;
    
    
    
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
        
    /**
     *  可以接受的类型
     */
    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
    [manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Accept"];


    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript", nil];
    
    if(requestSerializerContentType){
        [manager.requestSerializer setValue:requestSerializerContentType forHTTPHeaderField:@"Content-Type"];
    }else{
        [manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
    }
//    [manager.requestSerializer setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
    /**
     *  请求超时的时间
     */
    manager.requestSerializer.timeoutInterval = 100;
    NSString *token = [[NSUserDefaults standardUserDefaults] valueForKey:@"token"];
    if (token) {
        [manager.requestSerializer setValue:token  forHTTPHeaderField:@"Authorization"];
//        NSLog(@"API_memberPlaceOrder--用户token==%@\n",token);
    }else{
        if([SSUserManager sharedUser].userModel.tempToken){
            token = [SSUserManager sharedUser].userModel.tempToken;
//            NSLog(@"API_memberPlaceOrder--访客token==%@\n",token);
            
            [manager.requestSerializer setValue:token  forHTTPHeaderField:@"Authorization"];
        }
        else{
            [manager.requestSerializer setValue:@"Basic Y2xpZW50LWFwOjFxYXp4c3cy"  forHTTPHeaderField:@"Authorization"];
        }
    }
    
    
    
//    NSString *finalURL = [API_BASEURL stringByAppendingString:url];
//    NSLog(@"请求的URL：%@",finalURL);
    
//    NSString *TempFinalURL = [API_BASEURL stringByAppendingString:portStr];
//    NSString *finalURL = [NSString stringWithFormat:@"%@%@",TempFinalURL,URLStr];
    NSLog(@"请求的URL：%@",finalURL);
    
    if(mimeTypeStr==nil||mimeTypeStr.length==0){
        mimeTypeStr = @"image/png";
    }
    
    [manager POST:finalURL parameters:parameDict headers:@{} constructingBodyWithBlock:^(id<AFMultipartFormData>  _Nonnull formData) {
        [formData appendPartWithFileData:fData name:@"file" fileName:fileNameStr mimeType:mimeTypeStr];
    } progress:^(NSProgress * _Nonnull uploadProgress) {
        uploadProgre(uploadProgress);
    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        success(responseObject);
        [weakSelf successHandling:responseObject requestUrl:finalURL];
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        failure(error);
    }];
}
//MimeTyp
//超文本标记语言文本.html text/html
//
//xml文档.xml text/xml
//
//XHTML文档.xhtml application/xhtml+xml
//
//普通文本.txt text/plain
//
//RTF文本.rtf application/rtf
//
//PDF文档.pdf application/pdf
//
//Microsoft Word文件.word application/msword
//
//PNG图像.png image/png
//
//GIF图形.gif image/gif
//
//JPEG图形.jpeg,.jpg image/jpeg
//
//au声音文件.au audio/basic
//
//MIDI音乐文件mid,.midi audio/midi,audio/x-midi
//
//RealAudio音乐文件.ra, .ram audio/x-pn-realaudio
//
//MPEG文件.mpg,.mpeg video/mpeg
//
//AVI文件.avi video/x-msvideo
//
//GZIP文件.gz application/x-gzip
//
//TAR文件.tar application/x-tar
//
//任意的二进制数据application/octet-stream
//
- (void)uploadFileWithFullUrl:(NSString *)finalURL Port:(NSString *)portStr withrequestSerializerContentType:(NSString *)requestSerializerContentType  withFileData:(NSData *)fData withFileName:(NSString *)fileNameStr withMimeType:(NSString *)mimeTypeStr withParame:(NSDictionary *)parameDict success:(void (^)(id _Nonnull responseObject))success progress:(nullable void (^)(NSProgress * _Nonnull))uploadProgre failure:(void (^)(NSError * _Nonnull error))failure {
    
    XSWeakSelf;
    
    
    
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
        
    /**
     *  可以接受的类型
     */
    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
    [manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Accept"];


    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript", nil];
    
    if(requestSerializerContentType){
        [manager.requestSerializer setValue:requestSerializerContentType forHTTPHeaderField:@"Content-Type"];
    }else{
        [manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
    }
//    [manager.requestSerializer setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
    /**
     *  请求超时的时间
     */
    manager.requestSerializer.timeoutInterval = 100;
    NSString *token = [[NSUserDefaults standardUserDefaults] valueForKey:@"token"];
    if (token) {
        [manager.requestSerializer setValue:token  forHTTPHeaderField:@"Authorization"];
//        NSLog(@"API_memberPlaceOrder--用户token==%@\n",token);
    }else{
        if([SSUserManager sharedUser].userModel.tempToken){
            token = [SSUserManager sharedUser].userModel.tempToken;
//            NSLog(@"API_memberPlaceOrder--访客token==%@\n",token);
            
            [manager.requestSerializer setValue:token  forHTTPHeaderField:@"Authorization"];
        }
        else{
            [manager.requestSerializer setValue:@"Basic Y2xpZW50LWFwOjFxYXp4c3cy"  forHTTPHeaderField:@"Authorization"];
        }
    }
    
    
    
//    NSString *finalURL = [API_BASEURL stringByAppendingString:url];
//    NSLog(@"请求的URL：%@",finalURL);
    
//    NSString *TempFinalURL = [API_BASEURL stringByAppendingString:portStr];
//    NSString *finalURL = [NSString stringWithFormat:@"%@%@",TempFinalURL,URLStr];
    NSLog(@"请求的URL：%@",finalURL);
    
    if(mimeTypeStr==nil||mimeTypeStr.length==0){
        mimeTypeStr = @"image/png";
    }
//    [manager POST:finalURL parameters:parameDict constructingBodyWithBlock:^(id<AFMultipartFormData>  _Nonnull formData) {
//
//        [formData appendPartWithFileData:fData name:@"upfile" fileName:fileNameStr mimeType:mimeTypeStr];
//        int a =  10;
//        } progress:^(NSProgress * _Nonnull uploadProgress) {
//            uploadProgre(uploadProgress);
//        } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
//            success(responseObject);
//        } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
//            failure(error);
//        }];
    [manager POST:finalURL parameters:parameDict headers:@{} constructingBodyWithBlock:^(id<AFMultipartFormData>  _Nonnull formData) {
        [formData appendPartWithFileData:fData name:@"upfile" fileName:fileNameStr mimeType:mimeTypeStr];
    } progress:^(NSProgress * _Nonnull uploadProgress) {
        uploadProgre(uploadProgress);
    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        success(responseObject);
        [weakSelf successHandling:responseObject requestUrl:finalURL];
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        failure(error);
    }];
}

- (void)POSTBodyForDataFullUrl:(NSString *)finalURL withrequestSerializerContentType:(NSString *)requestSerializerContentType parameters:(id)parameters  withMimeType:(NSString *)mimeTypeStr progress:(nullable void (^)(NSProgress * _Nonnull))uploadProgre success:(void (^)(id _Nonnull sucee))success failure:(void (^)(NSError * _Nonnull err))failure {
    
    XSWeakSelf;
    
    
    
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
        
    /**
     *  可以接受的类型
     */
    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
    [manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Accept"];


    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript", nil];
    
    if(requestSerializerContentType){
        [manager.requestSerializer setValue:requestSerializerContentType forHTTPHeaderField:@"Content-Type"];
    }else{
        [manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
    }
//    [manager.requestSerializer setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
    /**
     *  请求超时的时间
     */
    manager.requestSerializer.timeoutInterval = 100;
    NSString *token = [[NSUserDefaults standardUserDefaults] valueForKey:@"token"];
    if (token) {
        [manager.requestSerializer setValue:token  forHTTPHeaderField:@"Authorization"];
//        NSLog(@"API_memberPlaceOrder--用户token==%@\n",token);
    }else{
        if([SSUserManager sharedUser].userModel.tempToken){
            token = [SSUserManager sharedUser].userModel.tempToken;
//            NSLog(@"API_memberPlaceOrder--访客token==%@\n",token);
            
            [manager.requestSerializer setValue:token  forHTTPHeaderField:@"Authorization"];
        }
        else{
            [manager.requestSerializer setValue:@"Basic Y2xpZW50LWFwOjFxYXp4c3cy"  forHTTPHeaderField:@"Authorization"];
        }
    }
    
    
    
//    NSString *finalURL = [API_BASEURL stringByAppendingString:url];
//    NSLog(@"请求的URL：%@",finalURL);
    
//    NSString *TempFinalURL = [API_BASEURL stringByAppendingString:portStr];
//    NSString *finalURL = [NSString stringWithFormat:@"%@%@",TempFinalURL,URLStr];
    

//    NSMutableString *dataStr = [NSMutableString new];
//    NSDictionary *parametersData = parameters;
//    if(parametersData.allKeys.count>0){
//        for (int i = 0; i < parametersData.count;  i ++) {
//            NSString *key = parametersData.allKeys[i];
//            id value = parametersData[key];
//            [dataStr appendFormat:@"%@=%@&",key,value];
//        }
//        NSString *postStr = [dataStr substringWithRange:NSMakeRange(0, dataStr.length - 1)];
//        finalURL = [NSString stringWithFormat:@"%@?%@",finalURL,postStr];
//    }
    
    NSLog(@"请求的URL：%@",finalURL);
    
    if(mimeTypeStr==nil||mimeTypeStr.length==0){
        mimeTypeStr = @"image/png";
    }
    
    [manager POST:finalURL parameters:parameters headers:@{} constructingBodyWithBlock:^(id<AFMultipartFormData>  _Nonnull formData) {
        
        NSData *imgData = [@"tempStr" dataUsingEncoding:NSUTF8StringEncoding];//[NSData alloc];//UIImagePNGRepresentation(tpImg);
        NSDateFormatter *formatter =[[NSDateFormatter alloc] init];
        [formatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
        NSString *dString = [formatter stringFromDate:[NSDate date]];

        NSString *fileNameStr = [NSString stringWithFormat:@"file001%@",dString];
        [formData appendPartWithFileData:imgData name:@"name" fileName:fileNameStr mimeType:@"image/png"];
        
    } progress:^(NSProgress * _Nonnull uploadProgress) {
        uploadProgre(uploadProgress);
    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
//        success(responseObject);
//        if (error !=nil) {
//            if (failure) {
//                failure(error);
//            }
//
//        }else{
            if ([responseObject isKindOfClass:[NSData class]]) {
                NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:responseObject options:kNilOptions error:nil];
                [weakSelf successHandling:dict requestUrl:finalURL];
                
                
//                    NSDictionary *dddd = [NSDictionary yy_modelWithJSON:data];
//                    NSLog(@"finalURL==%@\n请求响应：%@",finalURL,temppStr);
//                    NSLog(@"dddd==%@\n",dddd);
                if (!dict) {
                    
#warning 暂时注释
#warning 暂时注释
#warning 暂时注释
#warning 暂时注释
//                        [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"token"];
//                        [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"cloudRootNodeID"];
//                        [[NSUserDefaults standardUserDefaults] synchronize];
//                        [[NSNotificationCenter defaultCenter] postNotificationName:@"authorLoginAccess" object:nil];

//                        [ZZMessageHud showMessage:@"登录失效，请重新登录" toView:[UIApplication sharedApplication].windows.firstObject];
                    
//                    NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)response;
//                    NSString *strCode = [NSString stringWithFormat:@"%ld",httpResponse.statusCode];
//                    if(!notNillStr(strCode)){
//                        strCode =@"401";
//                    }
//                    NSDictionary *eroDict = @{@"code":strCode,@"msg":@"登录失效",@"data":@""};
//                    NSString *temppStr = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
//                    if(temppStr){
//                        eroDict = @{@"code":@"401",@"msg":@"返回有误",@"data":temppStr};
//                    }
                    if (success) {
                        success(@{@"code":@"401",@"msg":@"返回有误",@"data":@"返回有误"});
                    }
                    return;
                }
                if (success) {
                    success(dict);
                }
                
            }
            else{
                if (success) {
                    success(responseObject);
                }
            }
//        }
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        failure(error);
    }];
}
@end

